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