Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/decklink/mac/include/DeckLinkAPIDispatch.cpp

Issue 509313002: Mac Video Capture: Add Blackmagic DeckLink SDK for Mac to third_party folder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor change in devscripts/licensecheck.pl. README.chromium quotes verbatim SDK description. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /* -LICENSE-START-
2 ** Copyright (c) 2009 Blackmagic Design
3 **
4 ** Permission is hereby granted, free of charge, to any person or organization
5 ** obtaining a copy of the software and accompanying documentation covered by
6 ** this license (the "Software") to use, reproduce, display, distribute,
7 ** execute, and transmit the Software, and to prepare derivative works of the
8 ** Software, and to permit third-parties to whom the Software is furnished to
9 ** do so, all subject to the following:
10 **
11 ** The copyright notices in the Software and this entire statement, including
12 ** the above license grant, this restriction and the following disclaimer,
13 ** must be included in all copies of the Software, in whole or in part, and
14 ** all derivative works of the Software, unless such copies or derivative
15 ** works are solely in the form of machine-executable object code generated by
16 ** a source language processor.
17 **
18 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 ** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
21 ** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
22 ** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
23 ** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 ** DEALINGS IN THE SOFTWARE.
25 ** -LICENSE-END-
26 */
27 /* DeckLinkAPIDispatch.cpp */
28
29 #include "DeckLinkAPI.h"
30 #include <pthread.h>
31
32 #if BLACKMAGIC_DECKLINK_API_MAGIC != 1
33 #error The DeckLink API version of DeckLinkAPIDispatch.cpp is not the sa me version as DeckLinkAPI.h
34 #endif
35
36 #define kDeckLinkAPI_BundlePath "/Library/Frameworks/DeckLinkAPI.framework"
37
38
39 typedef IDeckLinkIterator* (*CreateIteratorFunc)(void);
40 typedef IDeckLinkAPIInformation* (*CreateAPIInformationFunc)(void);
41 typedef IDeckLinkGLScreenPreviewHelper* (*CreateOpenGLScreenPreviewHelperFunc)(v oid);
42 typedef IDeckLinkCocoaScreenPreviewCallback* (*CreateCocoaScreenPreviewFunc)(voi d*);
43 typedef IDeckLinkVideoConversion* (*CreateVideoConversionInstanceFunc)(void);
44 typedef IDeckLinkDiscovery* (*CreateDeckLinkDiscoveryInstanceFunc)(void);
45
46 static pthread_once_t gDeckLinkOnceCon trol = PTHREAD_ONCE_INIT;
47 static CFBundleRef gDeckLin kAPIBundleRef = NULL;
48 static CreateIteratorFunc gCreateIteratorF unc = NULL;
49 static CreateAPIInformationFunc gCreateAPIInformationFun c = NULL;
50 static CreateOpenGLScreenPreviewHelperFunc gCreateOpenGLPreviewFunc = NULL;
51 static CreateCocoaScreenPreviewFunc gCreateCocoaPreviewFunc = NULL;
52 static CreateVideoConversionInstanceFunc gCreateVideoConversionFunc = NULL;
53 static CreateDeckLinkDiscoveryInstanceFunc gCreateDeckLinkDiscoveryFunc= NULL;
54
55
56 void InitDeckLinkAPI (void)
57 {
58 CFURLRef bundleURL;
59
60 bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR(kDe ckLinkAPI_BundlePath), kCFURLPOSIXPathStyle, true);
61 if (bundleURL != NULL)
62 {
63 gDeckLinkAPIBundleRef = CFBundleCreate(kCFAllocatorDefault, bund leURL);
64 if (gDeckLinkAPIBundleRef != NULL)
65 {
66 gCreateIteratorFunc = (CreateIteratorFunc)CFBundleGetFun ctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateDeckLinkIteratorInstance _0002"));
67 gCreateAPIInformationFunc = (CreateAPIInformationFunc)CF BundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateDeckLinkAPII nformationInstance_0001"));
68 gCreateOpenGLPreviewFunc = (CreateOpenGLScreenPreviewHel perFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateOp enGLScreenPreviewHelper_0001"));
69 gCreateCocoaPreviewFunc = (CreateCocoaScreenPreviewFunc) CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateCocoaScree nPreview_0001"));
70 gCreateVideoConversionFunc = (CreateVideoConversionInsta nceFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateVi deoConversionInstance_0001"));
71 gCreateDeckLinkDiscoveryFunc = (CreateDeckLinkDiscoveryInstanceFunc) CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateDeckLinkDi scoveryInstance_0001"));
72 }
73 CFRelease(bundleURL);
74 }
75 }
76
77 bool IsDeckLinkAPIPresent (void)
78 {
79 // If the DeckLink API bundle was successfully loaded, return this knowl edge to the caller
80 if (gDeckLinkAPIBundleRef != NULL)
81 return true;
82
83 return false;
84 }
85
86 IDeckLinkIterator* CreateDeckLinkIteratorInstance (void)
87 {
88 pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
89
90 if (gCreateIteratorFunc == NULL)
91 return NULL;
92
93 return gCreateIteratorFunc();
94 }
95
96 IDeckLinkAPIInformation* CreateDeckLinkAPIInformationInstance (void)
97 {
98 pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
99
100 if (gCreateAPIInformationFunc == NULL)
101 return NULL;
102
103 return gCreateAPIInformationFunc();
104 }
105
106 IDeckLinkGLScreenPreviewHelper* CreateOpenGLScreenPreviewHelper (void)
107 {
108 pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
109
110 if (gCreateOpenGLPreviewFunc == NULL)
111 return NULL;
112
113 return gCreateOpenGLPreviewFunc();
114 }
115
116 IDeckLinkCocoaScreenPreviewCallback* CreateCocoaScreenPreview (void* parentVi ew)
117 {
118 pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
119
120 if (gCreateCocoaPreviewFunc == NULL)
121 return NULL;
122
123 return gCreateCocoaPreviewFunc(parentView);
124 }
125
126 IDeckLinkVideoConversion* CreateVideoConversionInstance (void)
127 {
128 pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
129
130 if (gCreateVideoConversionFunc == NULL)
131 return NULL;
132
133 return gCreateVideoConversionFunc();
134 }
135
136 IDeckLinkDiscovery* CreateDeckLinkDiscoveryInstance (void)
137 {
138 pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
139
140 if (gCreateDeckLinkDiscoveryFunc == NULL)
141 return NULL;
142
143 return gCreateDeckLinkDiscoveryFunc();
144 }
145
146
147 #define kBMDStreamingAPI_BundlePath "/Library/Application Support/Blackmagic Des ign/Streaming/BMDStreamingAPI.bundle"
148
149 typedef IBMDStreamingDiscovery* (*CreateDiscoveryFunc)(void);
150 typedef IBMDStreamingH264NALParser* (*CreateNALParserFunc)(void);
151
152 static pthread_once_t gBMDStreamingOnceControl = PTHREAD_ONCE_INIT;
153 static CFBundleRef gBMDStreamingAPIBundleRef = NULL;
154 static CreateDiscoveryFunc gCreateDiscoveryFunc = NULL;
155 static CreateNALParserFunc gCreateNALParserFunc = NULL;
156
157 void InitBMDStreamingAPI(void)
158 {
159 CFURLRef bundleURL;
160
161 bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR(kBM DStreamingAPI_BundlePath), kCFURLPOSIXPathStyle, true);
162 if (bundleURL != NULL)
163 {
164 gBMDStreamingAPIBundleRef = CFBundleCreate(kCFAllocatorDefault, bundleURL);
165 if (gBMDStreamingAPIBundleRef != NULL)
166 {
167 gCreateDiscoveryFunc = (CreateDiscoveryFunc)CFBundleGetF unctionPointerForName(gBMDStreamingAPIBundleRef, CFSTR("CreateBMDStreamingDiscov eryInstance_0001"));
168 gCreateNALParserFunc = (CreateNALParserFunc)CFBundleGetF unctionPointerForName(gBMDStreamingAPIBundleRef, CFSTR("CreateBMDStreamingH264NA LParser_0001"));
169 }
170
171 CFRelease(bundleURL);
172 }
173 }
174
175 IBMDStreamingDiscovery* CreateBMDStreamingDiscoveryInstance()
176 {
177 pthread_once(&gBMDStreamingOnceControl, InitBMDStreamingAPI);
178
179 if (gCreateDiscoveryFunc == NULL)
180 return NULL;
181
182 return gCreateDiscoveryFunc();
183 }
184
185 IBMDStreamingH264NALParser* CreateBMDStreamingH264NALParser()
186 {
187 pthread_once(&gBMDStreamingOnceControl, InitBMDStreamingAPI);
188
189 if (gCreateNALParserFunc == NULL)
190 return NULL;
191
192 return gCreateNALParserFunc();
193 }
OLDNEW
« no previous file with comments | « third_party/decklink/mac/include/DeckLinkAPIDiscovery.h ('k') | third_party/decklink/mac/include/DeckLinkAPIDispatch_v7_6.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698