OpenShot Library | libopenshot  0.2.5
DecklinkWriter.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Header file for DecklinkWriter class
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  *
6  * @ref License
7  */
8 
9 /* LICENSE
10  *
11  * Copyright (c) 2008-2019 OpenShot Studios, LLC
12  * <http://www.openshotstudios.com/>. This file is part of
13  * OpenShot Library (libopenshot), an open-source project dedicated to
14  * delivering high quality video editing and animation solutions to the
15  * world. For more information visit <http://www.openshot.org/>.
16  *
17  * OpenShot Library (libopenshot) is free software: you can redistribute it
18  * and/or modify it under the terms of the GNU Lesser General Public License
19  * as published by the Free Software Foundation, either version 3 of the
20  * License, or (at your option) any later version.
21  *
22  * OpenShot Library (libopenshot) is distributed in the hope that it will be
23  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU Lesser General Public License for more details.
26  *
27  * You should have received a copy of the GNU Lesser General Public License
28  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
29  */
30 
31 #ifndef OPENSHOT_DECKLINK_WRITER_H
32 #define OPENSHOT_DECKLINK_WRITER_H
33 
34 #include "WriterBase.h"
35 
36 #include <cmath>
37 #include <ctime>
38 #include <fcntl.h>
39 #include <iostream>
40 #include <omp.h>
41 #include <pthread.h>
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <string.h>
45 #include <memory>
46 #include <unistd.h>
47 
48 #include "CacheMemory.h"
49 #include "Exceptions.h"
50 #include "Frame.h"
51 #include "DecklinkOutput.h"
52 
53 namespace openshot
54 {
55 
56  /**
57  * @brief This class uses the Blackmagic Decklink libraries, to send video streams to Blackmagic devices.
58  *
59  * This requires special hardware manufactured by <a href="http://www.blackmagicdesign.com/products">Blackmagic Designs</a>.
60  * Once the device is acquired and connected, this reader returns openshot::Frame objects containing the image and audio data.
61  */
62  class DecklinkWriter : public WriterBase
63  {
64  private:
65  bool is_open;
66 
67  IDeckLink *deckLink;
68  IDeckLinkDisplayModeIterator *displayModeIterator;
69  IDeckLinkOutput *deckLinkOutput;
70  IDeckLinkVideoConversion *m_deckLinkConverter;
71  pthread_mutex_t sleepMutex;
72  pthread_cond_t sleepCond;
73  IDeckLinkIterator *deckLinkIterator;
74  DeckLinkOutputDelegate *delegate;
75  IDeckLinkDisplayMode *displayMode;
76  BMDVideoInputFlags inputFlags;
77  BMDDisplayMode selectedDisplayMode;
78  BMDPixelFormat pixelFormat;
79  int displayModeCount;
80  int exitStatus;
81  int ch;
82  bool foundDisplayMode;
83  HRESULT result;
84  int g_videoModeIndex;
85  int g_audioChannels;
86  int g_audioSampleDepth;
87  int g_maxFrames;
88  int device;
89 
90  public:
91 
92  /// Constructor for DecklinkWriter. This automatically opens the device or it
93  /// throws one of the following exceptions.
94  DecklinkWriter(int device, int video_mode, int pixel_format, int channels, int sample_depth);
95 
96  /// Close the device and video stream
97  void Close();
98 
99  /// This method is required for all derived classes of WriterBase. Write a Frame to the video file.
100  void WriteFrame(std::shared_ptr<Frame> frame);
101 
102  /// This method is required for all derived classes of WriterBase. Write a block of frames from a reader.
103  void WriteFrame(ReaderBase* reader, int start, int length);
104 
105  /// Open device and video stream - which is called by the constructor automatically
106  void Open();
107 
108  /// Determine if writer is open or closed
109  bool IsOpen() { return is_open; };
110 
111 
112  };
113 
114 }
115 
116 #endif
WriterBase.h
Header file for WriterBase class.
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: AudioBufferSource.h:38
openshot::DecklinkWriter
This class uses the Blackmagic Decklink libraries, to send video streams to Blackmagic devices.
Definition: DecklinkWriter.h:62
openshot::DecklinkWriter::IsOpen
bool IsOpen()
Determine if writer is open or closed.
Definition: DecklinkWriter.h:109
openshot::DecklinkWriter::Close
void Close()
Close the device and video stream.
Definition: DecklinkWriter.cpp:193
CacheMemory.h
Header file for CacheMemory class.
openshot::DecklinkWriter::Open
void Open()
Open device and video stream - which is called by the constructor automatically.
Definition: DecklinkWriter.cpp:60
Frame.h
Header file for Frame class.
openshot::DecklinkWriter::WriteFrame
void WriteFrame(std::shared_ptr< Frame > frame)
This method is required for all derived classes of WriterBase. Write a Frame to the video file.
Definition: DecklinkWriter.cpp:233
openshot::DecklinkWriter::DecklinkWriter
DecklinkWriter(int device, int video_mode, int pixel_format, int channels, int sample_depth)
Definition: DecklinkWriter.cpp:35
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:97
DecklinkOutput.h
Header file for DecklinkOutput class.
DeckLinkOutputDelegate
Implementation of the Blackmagic Decklink API (used by the DecklinkWriter)
Definition: DecklinkOutput.h:78
Exceptions.h
Header file for all Exception classes.
openshot::WriterBase
This abstract class is the base class, used by writers. Writers are types of classes that encode vide...
Definition: WriterBase.h:87