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