Wasabi ExpressPlay SDK for Embedded Systems
1.10
Main Page
Modules
Data Structures
Files
File List
Globals
Client
Source
Interface
Core
WsbMediaAccess.h
Go to the documentation of this file.
1
/*****************************************************************
2
|
3
| Wasabi - Media Access API
4
|
5
| $Id: WsbMediaAccess.h 10793 2014-06-25 12:46:08Z jebaseelir $
6
| Original author: Gilles Boccon-Gibod
7
|
8
| This software is provided to you pursuant to your agreement
9
| with Intertrust Technologies Corporation ("Intertrust").
10
| This software may be used only in accordance with the terms
11
| of the agreement.
12
|
13
| Copyright (c) 2008-2014 by Intertrust. All rights reserved.
14
|
15
****************************************************************/
21
#ifndef _WSB_MEDIA_ACCESS_H_
22
#define _WSB_MEDIA_ACCESS_H_
23
24
/*----------------------------------------------------------------------
25
| includes
26
+---------------------------------------------------------------------*/
27
#include "
WsbTypes.h
"
28
#include "
WsbElements.h
"
29
#include "
WsbMediaFile.h
"
30
31
/*----------------------------------------------------------------------
32
| types
33
+---------------------------------------------------------------------*/
34
35
41
typedef
struct
WSB_MediaSource
WSB_MediaSource
;
42
43
47
typedef
enum
{
48
WSB_MEDIA_SOURCE_EVENT_STATE_CHANGED
= 0,
49
WSB_MEDIA_SOURCE_EVENT_PRESENTATION
,
50
WSB_MEDIA_SOURCE_EVENT_PERIOD
,
51
WSB_MEDIA_SOURCE_EVENT_INIT_SEGMENT
,
52
WSB_MEDIA_SOURCE_EVENT_MEDIA_SEGMENT
,
53
WSB_MEDIA_SOURCE_EVENT_MEDIA_DATA
,
54
WSB_MEDIA_SOURCE_EVENT_SEEK_DONE
,
55
WSB_MEDIA_SOURCE_EVENT_START_DONE
,
56
WSB_MEDIA_SOURCE_EVENT_STOP_DONE
,
57
WSB_MEDIA_SOURCE_EVENT_FLUSH_DONE
58
}
WSB_MediaSourceEventType
;
59
63
typedef
enum
{
64
WSB_MEDIA_SOURCE_STATE_IDLE
,
65
WSB_MEDIA_SOURCE_STATE_RUNNING
,
66
WSB_MEDIA_SOURCE_STATE_STOPPED
67
}
WSB_MediaSourceState
;
68
72
typedef
enum
{
73
WSB_MEDIA_PRESENTATION_TYPE_MPEG_DASH
74
}
WSB_MediaPresentationType
;
75
79
typedef
enum
{
80
WSB_MEDIA_PRESENTATION_MODE_STATIC
,
81
WSB_MEDIA_PRESENTATION_MODE_DYNAMIC
82
}
WSB_MediaPresentationMode
;
83
87
typedef
enum
{
88
WSB_MEDIA_CONTAINER_FORMAT_MP4
,
89
WSB_MEDIA_CONTAINER_FORMAT_MPEG2TS
90
}
WSB_MediaContainerFormat
;
91
95
typedef
enum
{
96
WSB_MEDIA_SEGMENT_TYPE_DASH_ISOFF
,
97
WSB_MEDIA_SEGMENT_TYPE_DASH_MP2T
98
}
WSB_MediaSegmentType
;
99
133
typedef
struct
{
135
WSB_UInt64
bandwidth
;
136
}
WSB_MediaSourceStatistics
;
137
143
typedef
struct
{
144
WSB_UInt32
type
;
/* see WSB_MediaSourceInfoExtension types */
145
WSB_Size
data_size
;
146
const
WSB_UInt8
*
data
;
147
}
WSB_MediaSourceInfoExtension
;
148
153
typedef
struct
{
154
WSB_MediaType
type
;
155
WSB_UInt32
format
;
156
WSB_UInt64
media_duration
;
157
WSB_UInt32
media_timescale
;
158
WSB_Size
codec_info_size
;
159
const
unsigned
char
*
codec_info
;
160
}
WSB_MediaSourceMediaInfo
;
161
165
typedef
struct
{
166
WSB_MediaPresentationType
type
;
167
WSB_MediaPresentationMode
mode
;
168
WSB_UInt64
duration
;
169
WSB_Element
*
details
;
170
}
WSB_MediaPresentationInfo
;
171
175
typedef
struct
{
176
WSB_Ordinal
period_index
;
177
WSB_UInt64
start
;
178
WSB_UInt64
duration
;
179
WSB_Element
*
details
;
180
}
WSB_MediaPeriodInfo
;
181
185
typedef
struct
{
186
WSB_MediaSegmentType
type
;
187
WSB_Ordinal
stream_index
;
188
const
char
*
representation_id
;
189
WSB_MediaContainerFormat
media_container_format
;
190
unsigned
int
media_info_count
;
191
const
WSB_MediaSourceMediaInfo
*
media_infos
;
192
}
WSB_MediaInitSegmentInfo
;
193
197
typedef
struct
{
198
WSB_MediaSegmentType
type
;
199
WSB_Ordinal
stream_index
;
200
const
char
*
representation_id
;
201
WSB_UInt32
segment_index
;
202
WSB_UInt32
fragment_index
;
203
WSB_UInt32
duration
;
204
WSB_UInt32
timescale
;
205
const
char
*
url
;
206
WSB_MediaSourceStatistics
stats
;
207
}
WSB_MediaSegmentInfo
;
208
212
typedef
struct
{
213
WSB_UInt32
algorithm_id
;
214
WSB_UInt8
kid[16];
215
const
char
*
content_id
;
216
unsigned
int
data_size
;
217
const
WSB_UInt8
*
data
;
218
}
WSB_DashCencInfo
;
219
223
typedef
struct
{
224
WSB_MediaSegmentInfo
base
;
225
const
WSB_DashCencInfo
*
cenc_info
;
226
}
WSB_DashIsoFfMediaSegmentInfo
;
227
231
typedef
struct
{
232
WSB_MediaSegmentType
type
;
233
WSB_Ordinal
stream_index
;
234
const
char
*
representation_id
;
235
WSB_Ordinal
media_info_id
;
236
unsigned
int
media_data_size
;
237
const
unsigned
char
*
media_data
;
238
}
WSB_MediaDataInfo
;
239
243
typedef
struct
{
244
WSB_MediaDataInfo
base
;
245
WSB_UInt64
dts
;
246
WSB_UInt64
cts
;
247
WSB_UInt32
duration
;
248
WSB_UInt32
flags
;
249
}
WSB_DashIsoFfMediaDataInfo
;
250
254
typedef
struct
{
255
const
char
*
representation_id
;
256
const
char
*
codecs
;
257
WSB_UInt64
bandwidth
;
258
WSB_Element
*
details
;
259
}
WSB_MediaRepresentationInfo
;
260
264
typedef
struct
{
265
const
char
*
language
;
266
WSB_Element
*
details
;
267
}
WSB_MediaStreamVariantInfo
;
268
272
typedef
struct
{
273
WSB_MediaSourceEventType
type
;
274
}
WSB_MediaSourceEvent
;
275
279
typedef
struct
{
280
WSB_MediaSourceEvent
base
;
281
WSB_MediaSourceState
state
;
282
WSB_Result
error_code
;
283
const
char
*
message
;
284
}
WSB_MediaSourceStateChangedEvent
;
285
290
typedef
struct
{
291
WSB_MediaSourceEvent
base
;
292
WSB_MediaPresentationInfo
*
presentation_info
;
293
unsigned
int
extension_count
;
294
const
WSB_MediaSourceInfoExtension
*
extensions
;
295
}
WSB_MediaSourcePresentationEvent
;
296
301
typedef
struct
{
302
WSB_MediaSourceEvent
base
;
303
WSB_MediaPeriodInfo
*
period_info
;
304
unsigned
int
extension_count
;
305
const
WSB_MediaSourceInfoExtension
*
extensions
;
306
}
WSB_MediaSourcePeriodEvent
;
307
314
typedef
struct
{
315
WSB_MediaSourceEvent
base
;
316
const
WSB_MediaInitSegmentInfo
*
init_segment_info
;
317
unsigned
int
extension_count
;
318
const
WSB_MediaSourceInfoExtension
*
extensions
;
319
}
WSB_MediaSourceInitSegmentEvent
;
320
325
typedef
struct
{
326
WSB_MediaSourceEvent
base
;
327
const
WSB_MediaSegmentInfo
*
segment_info
;
328
unsigned
int
extension_count
;
329
const
WSB_MediaSourceInfoExtension
*
extensions
;
330
}
WSB_MediaSourceMediaSegmentEvent
;
331
336
typedef
struct
{
337
WSB_MediaSourceEvent
base
;
338
const
WSB_MediaDataInfo
*
data_info
;
339
unsigned
int
extension_count
;
340
const
WSB_MediaSourceInfoExtension
*
extensions
;
341
}
WSB_MediaSourceMediaDataEvent
;
342
346
typedef
struct
{
347
WSB_MediaSourceEvent
base
;
348
WSB_Result
seek_result
;
349
}
WSB_MediaSourceSeekDoneEvent
;
350
354
typedef
struct
{
355
WSB_MediaSourceEvent
base
;
356
WSB_Result
start_result
;
357
}
WSB_MediaSourceStartDoneEvent
;
358
362
typedef
struct
{
363
WSB_MediaSourceEvent
base
;
364
WSB_Result
stop_result
;
365
}
WSB_MediaSourceStopDoneEvent
;
366
370
typedef
struct
{
371
WSB_MediaSourceEvent
base
;
372
WSB_Result
flush_result
;
373
}
WSB_MediaSourceFlushDoneEvent
;
374
378
typedef
struct
WSB_MediaSourceListenerInstance
WSB_MediaSourceListenerInstance
;
379
typedef
struct
WSB_MediaSourceListenerInterface
WSB_MediaSourceListenerInterface
;
380
typedef
struct
{
381
WSB_MediaSourceListenerInstance
*
instance
;
382
const
WSB_MediaSourceListenerInterface
*
iface
;
383
}
WSB_MediaSourceListener
;
384
385
struct
WSB_MediaSourceListenerInterface
{
418
void (*
OnEvent
)(
const
WSB_MediaSourceListener
*
self
,
419
const
WSB_MediaSourceEvent
* event);
420
};
421
425
typedef
struct
WSB_MediaSourceCodecFilterInstance
WSB_MediaSourceCodecFilterInstance
;
426
typedef
struct
WSB_MediaSourceCodecFilterInterface
WSB_MediaSourceCodecFilterInterface
;
427
typedef
struct
{
428
WSB_MediaSourceCodecFilterInstance
*
instance
;
429
const
WSB_MediaSourceCodecFilterInterface
*
iface
;
430
}
WSB_MediaSourceCodecFilter
;
431
432
struct
WSB_MediaSourceCodecFilterInterface
{
445
int (*
IsCodecSupported
)(
const
WSB_MediaSourceCodecFilter
*
self
,
446
WSB_MediaType
media_type,
447
const
char
* codec);
448
};
449
454
typedef
struct
WSB_MediaSourceStreamSelectorInstance
WSB_MediaSourceStreamSelectorInstance
;
455
typedef
struct
WSB_MediaSourceStreamSelectorInterface
WSB_MediaSourceStreamSelectorInterface
;
456
typedef
struct
{
457
WSB_MediaSourceStreamSelectorInstance
*
instance
;
458
const
WSB_MediaSourceStreamSelectorInterface
*
iface
;
459
}
WSB_MediaSourceStreamSelector
;
460
461
struct
WSB_MediaSourceStreamSelectorInterface
{
484
int (*
SelectStream
)(
const
WSB_MediaSourceStreamSelector
*
self
,
485
WSB_MediaType
media_type,
486
unsigned
int
stream_count,
487
const
WSB_MediaStreamVariantInfo
** streams);
488
};
489
494
typedef
struct
WSB_MediaSourceRepresentationSelectorInstance
WSB_MediaSourceRepresentationSelectorInstance
;
495
typedef
struct
WSB_MediaSourceRepresentationSelectorInterface
WSB_MediaSourcRepresentationSelectorInterface
;
496
typedef
struct
{
497
WSB_MediaSourceRepresentationSelectorInstance
*
instance
;
498
const
WSB_MediaSourceRepresentationSelectorInterface
*
iface
;
499
}
WSB_MediaSourceRepresentationSelector
;
500
501
struct
WSB_MediaSourceRepresentationSelectorInterface
{
527
int (*
SelectRepresentation
)(
528
const
WSB_MediaSourceRepresentationSelector
*
self
,
529
WSB_MediaType
media_type,
530
unsigned
int
representation_count,
531
const
WSB_MediaRepresentationInfo
** representations,
532
const
WSB_MediaSourceStatistics
* statistics);
533
};
534
538
typedef
struct
{
539
WSB_Cardinal
max_audio_bytes_in_queue
;
540
WSB_Cardinal
max_video_bytes_in_queue
;
/* TS accounted as video */
541
WSB_UInt32
max_bitrate
;
/* used by default stream selector */
542
WSB_UInt32
max_height
;
/* used by default stream selector */
543
WSB_UInt32
max_width
;
/* used by default stream selector */
544
const
char
*
prefered_language
;
/* used by default stream selector */
545
WSB_Boolean
create_stopped
;
/* WSB_FALSE by default */
546
double
segment_retry_period
;
/* seconds between failed fetch retries */
547
}
WSB_MediaSourceConfig
;
548
552
typedef
struct
{
553
WSB_Size
audio_bytes_in_queue
;
554
WSB_Size
video_bytes_in_queue
;
555
WSB_Size
audio_duration_in_queue
;
/* in milliseconds */
556
WSB_Size
video_duration_in_queue
;
/* in milliseconds */
557
}
WSB_MediaSourceStatus
;
558
559
typedef
enum
{
560
WSB_MEDIA_DATA_DECRYPTER_TYPE_CENC
561
}
WSB_MediaDataDecrypterType
;
562
563
typedef
enum
{
564
WSB_MEDIA_DATA_DECRYPTER_KEY_FORMAT_RAW
,
565
WSB_MEDIA_DATA_DECRYPTER_KEY_FORMAT_SKB
566
}
WSB_MediaDataDecrypterKeyFormat
;
567
574
typedef
enum
{
576
WSB_SEEK_FLAG_BOTH
,
578
WSB_SEEK_FLAG_VIDEO_ONLY
,
580
WSB_SEEK_FLAG_AUDIO_ONLY
581
}
WSB_MediaSourceSeekFlag
;
582
589
typedef
enum
{
591
WSB_FLUSH_FLAG_BOTH
,
593
WSB_FLUSH_FLAG_VIDEO_ONLY
,
595
WSB_FLUSH_FLAG_AUDIO_ONLY
596
}
WSB_MediaSourceFlushFlag
;
597
604
typedef
enum
{
606
WSB_RESUME_FLAG_FROM_CURRENT_POSITON
,
608
WSB_RESUME_FLAG_CATCHUP_TO_LIVE
609
}
WSB_MediaSourceResumeFlag
;
610
611
/*----------------------------------------------------------------------
612
| constants
613
+---------------------------------------------------------------------*/
614
#define WSB_MEDIA_SOURCE_TIMEOUT_INFINITE ((WSB_Int32)(-1))
615
616
/* WSB_DashIsoFfMediaDataInfo flags */
617
#define WSB_DASH_ISOFF_MEDIA_DATA_FLAG_SYNC 1
618
619
/* WSB_MediaSourceInfoExtension types */
620
#define WSB_MEDIA_SOURCE_INFO_EXTENSION_TYPE_PSSH 0x70737368
/* 'pssh' */
621
622
/* Return values for stream and representation selectors */
623
#define WSB_MEDIA_SOURCE_USE_DEFAULT_SELECTOR (-1)
624
#define WSB_MEDIA_SOURCE_NO_COMPATIBLE_SELECTION (-2)
625
626
/*----------------------------------------------------------------------
627
| functions
628
+---------------------------------------------------------------------*/
629
#if defined(__cplusplus)
630
extern
"C"
{
631
#endif
632
659
WSB_EXPORT
WSB_Result
660
WSB_MediaSource_Create
(
661
const
char
* url,
662
const
char
* mime_type,
663
const
WSB_MediaSourceListener
* listener,
664
const
WSB_MediaSourceCodecFilter
* codec_filter,
665
const
WSB_MediaSourceStreamSelector
* stream_selector,
666
const
WSB_MediaSourceRepresentationSelector
* representation_selector,
667
const
WSB_MediaSourceConfig
* config,
668
WSB_MediaSource
** source);
669
685
WSB_EXPORT
WSB_Result
686
WSB_MediaSource_Start
(
WSB_MediaSource
*
self
,
WSB_MediaSourceResumeFlag
resume_flag);
687
700
WSB_EXPORT
WSB_Result
701
WSB_MediaSource_Stop
(
WSB_MediaSource
*
self
);
702
722
WSB_EXPORT
WSB_Result
723
WSB_MediaSource_Flush
(
WSB_MediaSource
*
self
,
WSB_MediaSourceFlushFlag
flush_flag);
724
738
WSB_EXPORT
WSB_Result
739
WSB_MediaSource_Advance
(
WSB_MediaSource
*
self
,
740
WSB_Int32
timeout);
741
757
WSB_EXPORT
WSB_Result
758
WSB_MediaSource_Seek
(
WSB_MediaSource
*
self
,
759
WSB_UInt64
position_in_ms,
760
WSB_MediaSourceSeekFlag
seek_flag);
761
774
WSB_EXPORT
WSB_Result
775
WSB_MediaSource_ReselectStreams
(
WSB_MediaSource
*
self
);
776
787
WSB_EXPORT
WSB_Result
788
WSB_MediaSource_GetStatus
(
WSB_MediaSource
*
self
,
789
WSB_MediaSourceStatus
* status);
790
799
WSB_EXPORT
WSB_Result
800
WSB_MediaSource_Destroy
(
WSB_MediaSource
*
self
);
801
809
typedef
struct
WSB_MediaDataDecrypter
WSB_MediaDataDecrypter
;
810
830
WSB_EXPORT
WSB_Result
831
WSB_MediaDataDecrypter_Create
(
WSB_MediaDataDecrypterType
type,
832
const
void
* init_info,
833
WSB_MediaDataDecrypterKeyFormat
key_format,
834
const
WSB_UInt8
* key,
835
unsigned
int
key_size,
836
WSB_MediaDataDecrypter
** decrypter);
837
853
WSB_EXPORT
WSB_Result
854
WSB_MediaDataDecrypter_Decrypt
(
WSB_MediaDataDecrypter
*
self
,
855
const
WSB_UInt8
* in,
856
unsigned
int
in_size,
857
WSB_UInt8
* out,
858
unsigned
int
* out_size);
859
868
WSB_EXPORT
WSB_Result
869
WSB_MediaDataDecrypter_Destroy
(
WSB_MediaDataDecrypter
*
self
);
870
873
#if defined(__cplusplus)
874
}
875
#endif
876
877
#endif
/* _WSB_MEDIA_ACCESS_H_ */