OpenShot Library | libopenshot  0.2.7
DecklinkOutput.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Header file for DecklinkOutput class
4  * @author Jonathan Thomas <jonathan@openshot.org>, Blackmagic Design
5  *
6  * @ref License
7  */
8 
9 // Copyright (c) 2008-2019 OpenShot Studios, LLC
10 // Copyright (c) 2009 Blackmagic Design
11 //
12 // SPDX-License-Identifier: LGPL-3.0-or-later
13 // SPDX-License-Identifier: MIT
14 
15 #ifndef OPENSHOT_DECKLINK_OUTPUT_H
16 #define OPENSHOT_DECKLINK_OUTPUT_H
17 
18 #include <iostream>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <pthread.h>
23 #include <unistd.h>
24 #include <fcntl.h>
25 
26 #include "DeckLinkAPI.h"
27 #include "CacheMemory.h"
28 #include "Frame.h"
29 #include "OpenMPUtilities.h"
30 
34 };
35 
36 /// Implementation of the Blackmagic Decklink API (used by the DecklinkWriter)
37 class DeckLinkOutputDelegate : public IDeckLinkVideoOutputCallback, public IDeckLinkAudioOutputCallback
38 {
39 protected:
40  unsigned long m_totalFramesScheduled;
44  unsigned long m_audioBufferOffset;
45  unsigned long m_audioChannelCount;
46  BMDAudioSampleRate m_audioSampleRate;
47  unsigned long m_audioSampleDepth;
48  unsigned long audioSamplesPerFrame;
49  unsigned long m_framesPerSecond;
50  int height;
51  int width;
52 
53  unsigned long frameCount;
54  //map<int, IDeckLinkMutableVideoFrame* > temp_cache;
55  std::map<int, uint8_t * > temp_cache;
56 
58 
59  // Queue of raw video frames
60  //deque<IDeckLinkMutableVideoFrame*> final_frames;
61  std::deque<uint8_t * > final_frames;
62  std::deque<std::shared_ptr<openshot::Frame> > raw_video_frames;
63 
64  // Convert between YUV and RGB
65  IDeckLinkOutput *deckLinkOutput;
66  IDeckLinkDisplayMode *displayMode;
67 
68  // Current frame being displayed
69  IDeckLinkMutableVideoFrame *m_currentFrame;
70 
71 public:
72  DeckLinkOutputDelegate(IDeckLinkDisplayMode *displayMode, IDeckLinkOutput* deckLinkOutput);
74 
75  // *** DeckLink API implementation of IDeckLinkVideoOutputCallback IDeckLinkAudioOutputCallback *** //
76  // IUnknown needs only a dummy implementation
77  virtual HRESULT STDMETHODCALLTYPE QueryInterface (REFIID iid, LPVOID *ppv) {return E_NOINTERFACE;}
78  virtual ULONG STDMETHODCALLTYPE AddRef () {return 1;}
79  virtual ULONG STDMETHODCALLTYPE Release () {return 1;}
80 
81  virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted (IDeckLinkVideoFrame* completedFrame, BMDOutputFrameCompletionResult result);
82  virtual HRESULT STDMETHODCALLTYPE ScheduledPlaybackHasStopped ();
83 
84  virtual HRESULT STDMETHODCALLTYPE RenderAudioSamples (bool preroll);
85 
86  /// Schedule the next frame
87  void ScheduleNextFrame(bool prerolling);
88 
89  /// Custom method to write new frames
90  void WriteFrame(std::shared_ptr<openshot::Frame> frame);
91 
92 private:
93  ULONG m_refCount;
94  pthread_mutex_t m_mutex;
95 };
96 
97 
98 #endif
std::deque< uint8_t *> final_frames
virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted(IDeckLinkVideoFrame *completedFrame, BMDOutputFrameCompletionResult result)
unsigned long m_audioBufferOffset
Implementation of the Blackmagic Decklink API (used by the DecklinkWriter)
std::deque< std::shared_ptr< openshot::Frame > > raw_video_frames
DeckLinkOutputDelegate(IDeckLinkDisplayMode *displayMode, IDeckLinkOutput *deckLinkOutput)
Header file for OpenMPUtilities (set some common macros)
IDeckLinkDisplayMode * displayMode
BMDTimeValue frameRateScale
Header file for CacheMemory class.
Header file for Frame class.
unsigned long m_audioSampleDepth
IDeckLinkMutableVideoFrame * m_currentFrame
unsigned long frameCount
OutputSignal
virtual ULONG STDMETHODCALLTYPE AddRef()
std::map< int, uint8_t *> temp_cache
void WriteFrame(std::shared_ptr< openshot::Frame > frame)
Custom method to write new frames.
unsigned long m_totalFramesScheduled
virtual ULONG STDMETHODCALLTYPE Release()
OutputSignal m_outputSignal
unsigned long m_audioChannelCount
IDeckLinkOutput * deckLinkOutput
unsigned long audioSamplesPerFrame
BMDAudioSampleRate m_audioSampleRate
BMDTimeValue frameRateDuration
virtual HRESULT STDMETHODCALLTYPE RenderAudioSamples(bool preroll)
virtual HRESULT STDMETHODCALLTYPE ScheduledPlaybackHasStopped()
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
unsigned long m_audioBufferSampleLength
void ScheduleNextFrame(bool prerolling)
Schedule the next frame.
unsigned long m_framesPerSecond