OpenShot Library | libopenshot  0.2.5
DecklinkInput.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Header file for DecklinkInput class
4  * @author Jonathan Thomas <jonathan@openshot.org>, Blackmagic Design
5  *
6  * @ref License
7  */
8 
9 /* LICENSE
10  *
11  * Copyright (c) 2009 Blackmagic Design
12  *
13  * Permission is hereby granted, free of charge, to any person or organization
14  * obtaining a copy of the software and accompanying documentation covered by
15  * this license (the "Software") to use, reproduce, display, distribute,
16  * execute, and transmit the Software, and to prepare derivative works of the
17  * Software, and to permit third-parties to whom the Software is furnished to
18  * do so, all subject to the following:
19  *
20  * The copyright notices in the Software and this entire statement, including
21  * the above license grant, this restriction and the following disclaimer,
22  * must be included in all copies of the Software, in whole or in part, and
23  * all derivative works of the Software, unless such copies or derivative
24  * works are solely in the form of machine-executable object code generated by
25  * a source language processor.
26  *
27  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
30  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
31  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
32  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
33  * DEALINGS IN THE SOFTWARE.
34  *
35  *
36  * Copyright (c) 2008-2019 OpenShot Studios, LLC
37  * <http://www.openshotstudios.com/>. This file is part of
38  * OpenShot Library (libopenshot), an open-source project dedicated to
39  * delivering high quality video editing and animation solutions to the
40  * world. For more information visit <http://www.openshot.org/>.
41  *
42  * OpenShot Library (libopenshot) is free software: you can redistribute it
43  * and/or modify it under the terms of the GNU Lesser General Public License
44  * as published by the Free Software Foundation, either version 3 of the
45  * License, or (at your option) any later version.
46  *
47  * OpenShot Library (libopenshot) is distributed in the hope that it will be
48  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
49  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50  * GNU Lesser General Public License for more details.
51  *
52  * You should have received a copy of the GNU Lesser General Public License
53  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
54  */
55 
56 #ifndef OPENSHOT_DECKLINK_INPUT_H
57 #define OPENSHOT_DECKLINK_INPUT_H
58 
59 #include <iostream>
60 #include <stdio.h>
61 #include <stdlib.h>
62 #include <string.h>
63 #include <pthread.h>
64 #include <unistd.h>
65 #include <fcntl.h>
66 
67 #include "DeckLinkAPI.h"
68 #include "Frame.h"
69 #include "CacheMemory.h"
70 #include "OpenMPUtilities.h"
71 
72 /// Implementation of the Blackmagic Decklink API (used by the DecklinkReader)
73 class DeckLinkInputDelegate : public IDeckLinkInputCallback
74 {
75 public:
76  pthread_cond_t* sleepCond;
77  BMDTimecodeFormat g_timecodeFormat;
78  unsigned long frameCount;
79  unsigned long final_frameCount;
80 
81  // Queue of raw video frames
82  std::deque<IDeckLinkMutableVideoFrame*> raw_video_frames;
84 
85  // Convert between YUV and RGB
86  IDeckLinkOutput *deckLinkOutput;
87  IDeckLinkVideoConversion *deckLinkConverter;
88 
89  DeckLinkInputDelegate(pthread_cond_t* m_sleepCond, IDeckLinkOutput* deckLinkOutput, IDeckLinkVideoConversion* deckLinkConverter);
91 
92  virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; }
93  virtual ULONG STDMETHODCALLTYPE AddRef(void);
94  virtual ULONG STDMETHODCALLTYPE Release(void);
95  virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags);
96  virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*);
97 
98  // Extra methods
99  std::shared_ptr<openshot::Frame> GetFrame(int64_t requested_frame);
100  unsigned long GetCurrentFrameNumber();
101 
102 private:
103  ULONG m_refCount;
104  pthread_mutex_t m_mutex;
105 };
106 
107 #endif
std::shared_ptr< openshot::Frame > GetFrame(int64_t requested_frame)
virtual ULONG STDMETHODCALLTYPE AddRef(void)
Header file for OpenMPUtilities (set some common macros)
std::deque< IDeckLinkMutableVideoFrame * > raw_video_frames
Definition: DecklinkInput.h:82
virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode *, BMDDetectedVideoInputFormatFlags)
Header file for CacheMemory class.
Header file for Frame class.
Implementation of the Blackmagic Decklink API (used by the DecklinkReader)
Definition: DecklinkInput.h:73
DeckLinkInputDelegate(pthread_cond_t *m_sleepCond, IDeckLinkOutput *deckLinkOutput, IDeckLinkVideoConversion *deckLinkConverter)
unsigned long frameCount
Definition: DecklinkInput.h:78
virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame *, IDeckLinkAudioInputPacket *)
unsigned long GetCurrentFrameNumber()
openshot::CacheMemory final_frames
Definition: DecklinkInput.h:83
virtual ULONG STDMETHODCALLTYPE Release(void)
unsigned long final_frameCount
Definition: DecklinkInput.h:79
BMDTimecodeFormat g_timecodeFormat
Definition: DecklinkInput.h:77
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
Definition: DecklinkInput.h:92
pthread_cond_t * sleepCond
Definition: DecklinkInput.h:76
IDeckLinkOutput * deckLinkOutput
Definition: DecklinkInput.h:86
IDeckLinkVideoConversion * deckLinkConverter
Definition: DecklinkInput.h:87
This class is a memory-based cache manager for Frame objects.
Definition: CacheMemory.h:51