UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
vidcap_avfoundation_state Class Reference
Inheritance diagram for vidcap_avfoundation_state:
Inheritance graph
Collaboration diagram for vidcap_avfoundation_state:
Collaboration graph

Instance Methods

(void) - captureOutput:didOutputSampleBuffer:fromConnection:
 
(struct video_frame *) - grab
 

Protected Attributes

AVCaptureDevice * m_device
 
double m_fps_req
 
condition_variable m_frame_ready
 
int m_frames
 
mutex m_lock
 
queue< struct video_frame * > m_queue
 
AVCaptureSession * m_session
 
chrono::steady_clock::time_point m_t0
 

Detailed Description

Definition at line 106 of file avfoundation.mm.

Method Documentation

◆ captureOutput:didOutputSampleBuffer:fromConnection:

- (void) captureOutput: (AVCaptureOutput *) captureOutput
didOutputSampleBuffer: (CMSampleBufferRef) sampleBuffer
fromConnection: (AVCaptureConnection *) connection 

Definition at line 115 of file avfoundation.mm.

437 :(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
438fromConnection:(AVCaptureConnection *)connection
439{
440#pragma unused (captureOutput)
441#pragma unused (connection)
442 unique_lock<mutex> lock(m_lock);
443 struct video_frame *frame = [self imageFromSampleBuffer: sampleBuffer];
444 if (frame) {
445 if (m_queue.size() < MAX_CAPTURE_QUEUE_SIZE) {
446 m_queue.push(frame);
447 lock.unlock();
448 m_frame_ready.notify_one();
449 } else {
450 NSLog(@"Frame dropped!");
452 }
453 }
454}
struct video_frame * frame
condition_variable m_frame_ready
queue< struct video_frame * > m_queue
constexpr int MAX_CAPTURE_QUEUE_SIZE
Struct video_frame represents a video frame and contains video description.
Definition types.h:305
#define VIDEO_FRAME_DISPOSE(frame)
Definition video_frame.h:76

◆ grab

- (struct video_frame *) grab

Definition at line 115 of file avfoundation.mm.

530{
531 unique_lock<mutex> lock(m_lock);
532 m_frame_ready.wait_for(lock, milliseconds(100), [&]{return m_queue.size() != 0;});
533 if (m_queue.size() == 0) {
534 return NULL;
535 } else {
536 struct video_frame *ret;
537 ret = m_queue.front();
538 m_queue.pop();
539
540 m_frames++;
541
542 chrono::steady_clock::time_point now = chrono::steady_clock::now();
543 double seconds = chrono::duration_cast<chrono::microseconds>(now - m_t0).count() / 1000000.0;
544 if (seconds >= 5) {
545 cout << "[AVfoundation capture] " << m_frames << " frames in "
546 << seconds << " seconds = " << m_frames / seconds << " FPS\n";
547 m_t0 = now;
548 m_frames = 0;
549 }
550
551 return ret;
552 }
553}
chrono::steady_clock::time_point m_t0

Member Data Documentation

◆ m_device

- (AVCaptureDevice*) m_device
protected

Definition at line 108 of file avfoundation.mm.

◆ m_fps_req

- (double) m_fps_req
protected

Definition at line 114 of file avfoundation.mm.

◆ m_frame_ready

- (condition_variable) m_frame_ready
protected

Definition at line 111 of file avfoundation.mm.

◆ m_frames

- (int) m_frames
protected

Definition at line 115 of file avfoundation.mm.

◆ m_lock

- (mutex) m_lock
protected

Definition at line 110 of file avfoundation.mm.

◆ m_queue

- (queue<struct video_frame *>) m_queue
protected

Definition at line 112 of file avfoundation.mm.

◆ m_session

- (AVCaptureSession*) m_session
protected

Definition at line 109 of file avfoundation.mm.

◆ m_t0

- steady_clock:
protected

Definition at line 113 of file avfoundation.mm.


The documentation for this class was generated from the following file: