OpenShot Library | libopenshot  0.2.7
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 // Copyright (c) 2008-2019 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_DECKLINK_WRITER_H
14 #define OPENSHOT_DECKLINK_WRITER_H
15 
16 #include "WriterBase.h"
17 
18 #include <cmath>
19 #include <ctime>
20 #include <fcntl.h>
21 #include <iostream>
22 #include <omp.h>
23 #include <pthread.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <memory>
28 #include <unistd.h>
29 
30 #include "CacheMemory.h"
31 #include "Frame.h"
32 #include "DecklinkOutput.h"
33 
34 namespace openshot
35 {
36 
37  /**
38  * @brief This class uses the Blackmagic Decklink libraries, to send video streams to Blackmagic devices.
39  *
40  * This requires special hardware manufactured by <a href="http://www.blackmagicdesign.com/products">Blackmagic Designs</a>.
41  * Once the device is acquired and connected, this reader returns openshot::Frame objects containing the image and audio data.
42  */
43  class DecklinkWriter : public WriterBase
44  {
45  private:
46  bool is_open;
47 
48  IDeckLink *deckLink;
49  IDeckLinkDisplayModeIterator *displayModeIterator;
50  IDeckLinkOutput *deckLinkOutput;
51  IDeckLinkVideoConversion *m_deckLinkConverter;
52  pthread_mutex_t sleepMutex;
53  pthread_cond_t sleepCond;
54  IDeckLinkIterator *deckLinkIterator;
55  DeckLinkOutputDelegate *delegate;
56  IDeckLinkDisplayMode *displayMode;
57  BMDVideoInputFlags inputFlags;
58  BMDDisplayMode selectedDisplayMode;
59  BMDPixelFormat pixelFormat;
60  int displayModeCount;
61  int exitStatus;
62  int ch;
63  bool foundDisplayMode;
64  HRESULT result;
65  int g_videoModeIndex;
66  int g_audioChannels;
67  int g_audioSampleDepth;
68  int g_maxFrames;
69  int device;
70 
71  public:
72 
73  /// Constructor for DecklinkWriter. This automatically opens the device or it
74  /// throws one of the following exceptions.
75  DecklinkWriter(int device, int video_mode, int pixel_format, int channels, int sample_depth);
76 
77  /// Close the device and video stream
78  void Close();
79 
80  /// This method is required for all derived classes of WriterBase. Write a Frame to the video file.
81  void WriteFrame(std::shared_ptr<Frame> frame);
82 
83  /// This method is required for all derived classes of WriterBase. Write a block of frames from a reader.
84  void WriteFrame(ReaderBase* reader, int start, int length);
85 
86  /// Open device and video stream - which is called by the constructor automatically
87  void Open();
88 
89  /// Determine if writer is open or closed
90  bool IsOpen() { return is_open; };
91 
92 
93  };
94 
95 }
96 
97 #endif
void WriteFrame(std::shared_ptr< Frame > frame)
This method is required for all derived classes of WriterBase. Write a Frame to the video file...
Implementation of the Blackmagic Decklink API (used by the DecklinkWriter)
Header file for DecklinkOutput class.
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:77
Header file for CacheMemory class.
bool IsOpen()
Determine if writer is open or closed.
Header file for Frame class.
Header file for WriterBase class.
This abstract class is the base class, used by writers. Writers are types of classes that encode vide...
Definition: WriterBase.h:69
DecklinkWriter(int device, int video_mode, int pixel_format, int channels, int sample_depth)
void Open()
Open device and video stream - which is called by the constructor automatically.
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
void Close()
Close the device and video stream.
This class uses the Blackmagic Decklink libraries, to send video streams to Blackmagic devices...