Upgrade of Widevine libraries from 4.5.0 to 6.0.0

Upload for Dave Parsons

6.0.0 Widevine libraries contain the features required
to support multiple audio tracks and subtitles.  This
is establishing the baseline for those features.

Change-Id: If12074bb2e4364c8107339e2f69453c40698e91f
related-to-bug: 5880566
This commit is contained in:
Jeff Tinker
2012-04-04 15:49:03 -07:00
parent e612ce59c4
commit 462dc030f8
14 changed files with 1004 additions and 119 deletions

View File

@@ -1,14 +1,17 @@
/*
* Copyright 2011 Widevine Technologies, Inc., All Rights Reserved
*
* Declarations for Widevine Adaptive Streaming API
*/
//
// Declarations for Widevine Adaptive Streaming API
//
// Copyright 2011 Widevine Technologies, Inc., All Rights Reserved
//
#ifndef __WV_STREAM_CONTROL_API_H__
#define __WV_STREAM_CONTROL_API_H__
#include <string>
#include <vector>
#include "WVStatus.h"
#include "WVTypes.h"
#include "WVControlSettings.h"
#if OS_WIN
#ifdef CLIENTAPI_EXPORTS
@@ -27,68 +30,12 @@ typedef enum WVLogging {
WV_Logging_ParseOutput = 2,
} WVLogging;
typedef enum WVStatus {
WV_Status_OK = 200,
WV_Status_Bad_Request = 400,
WV_Status_Unauthorized = 401,
WV_Status_Not_Found = 404,
WV_Status_Method_Not_Allowed = 405,
WV_Status_Request_Timeout = 408,
WV_Status_Unsupported_Media_Type = 415,
WV_Status_Requested_Range_Not_Satisfiable = 416,
WV_Status_Invalid_Parameter = 451,
WV_Status_Session_Not_Found = 454,
WV_Status_Method_Not_Valid_In_This_State = 455,
WV_Status_Invalid_Range = 457,
WV_Status_Unsupported_Transport = 461,
WV_Status_Destination_Unreachable = 462,
WV_Status_Terminate_Requested = 463,
WV_Status_Internal_Server_Error = 500,
WV_Status_Not_Implemented = 501,
WV_Status_Service_Unavailable = 503,
WV_Status_Service_Response_Error = 504,
WV_Status_Min_TP_Error = 512, // Error codes 512-768 are reserved for
WV_Status_Max_TP_Error = 768, // Third Party apps (Cinema Now)
WV_Status_End_Of_Media = 1000,
WV_Status_Invalid_Data_Format = 1001,
WV_Status_Invalid_Data_Version = 1002,
WV_Status_Parse_Error = 1003,
WV_Status_Tamper_Detected = 1004,
WV_Status_Truncated_Media = 1005,
WV_Status_WVMK_Internal_Error = 1006,
WV_Status_Entitlement_Error = 1007,
WV_Status_Key_Error = 1008,
WV_Status_Value_Out_Of_Range = 1009,
WV_Status_System_Error = 1010,
WV_Status_Invalid_Response = 1011,
WV_Status_Unsupported_Transport_Type = 1012,
WV_Status_FileSystem_Error = 1013,
WV_Status_User_Cancel = 1014,
WV_Status_InvalidState = 1015,
WV_Status_InvalidPiggybackFile = 1016,
WV_Status_Configuration_Error= 1017,
WV_Status_Warning_Download_Stalled = 2000,
WV_Status_Warning_Need_Key = 2001,
WV_Status_Warning_Not_Available = 2002,
WV_Status_Checking_Bandwidth = 2003,
WV_Status_Error_Download_Stalled = 2004,
WV_Status_Error_Need_Key = 2005,
WV_Status_Error_Out_Of_Memory = 2006,
WV_Status_Uninitialized = 2007,
WV_Status_Internal_Error = 2008,
WV_Status_Error_Invalid_Chapter = 2009,
WV_Status_Heartbeat_Configuration_Error = 2010,
WV_Status_Invalid_Keybox = 2011,
WV_Status_Error_NoAdaptiveTracks = 2012,
WV_Status_Warning_ContinuityErrorCounter = 2014,
} WVStatus;
typedef enum WVOutputFormat {
WV_OutputFormat_PS = 0, // Generic program stream
WV_OutputFormat_DVD_Video = 1, // DVD-Video program stream
WV_OutputFormat_TS = 2, // Transport Stream
WV_OutputFormat_ES = 3 // Elementary Streams
WV_OutputFormat_ES = 3, // Elementary Streams
WV_OutputFormat_DVD_Video_No_EAC3_Framing = 4 // DVD-Video without Dolby Digital+ audio framing
} WVOutputFormat;
@@ -99,46 +46,61 @@ typedef enum WVEsSelector {
} WVEsSelector;
struct WVCredentials {
std::string deviceID; // unique player device ID from CinemaNow
std::string streamID; // unique streamID from CinemaNow
std::string clientIP; // IP address of client
std::string drmServerURL; // URL for DRM server
std::string userData; // Additional optional user data, TBD
std::string portal; // Identifies the operator
std::string storefront; // Identifies store run by operator
std::string drmAckServerURL; // URL for server that receives
// entitlement confirmations
std::string heartbeatURL; // URL to receive client heartbeats
unsigned int heartbeatPeriod;// Duration between consecutive heartbeats in
// seconds. 0 indicates no heatbeats requested
unsigned int cnDeviceType; // device type identifier defined by CinemaNow
};
struct WVProxySettings {
bool enable; // If true, proxy use is enable, otherwise disabled
std::string ipAddr; // IP address of proxy server, e.g. "1.2.3.4" or host name
unsigned short ipPort; // IP port number
std::string userId; // User ID if authentication is needed, otherwise "" to disable authentication
std::string password; // Password if userID is not ""
};
#define UNSPECIFIED_TRACK_ID WVUnsignedInt(0)
class WVSession;
//
// Callbacks used for RTSP direct function call implementation and/or
// direct function call push data model.
// Also buffer allocation routines for using an external allocator
//
typedef void (*WVDecryptCallback)(WVEsSelector esType, void* input, void* output, size_t length, int key);
// Provide info on socket open/close operations for bandwidth attribution
// status: {0=open, 1=close}
typedef void (*WVSocketInfoCallback)(int fd, int status, void *context);
typedef void (*WVSocketInfoCallback)(int fd, int status, void * context);
//
// CALLBACK: WVDecryptCallback
//
// Gets called to decrypt individual crypto units
//
// Parameters:
// [in] es_type - Type of elementary stream, indicating audio or video
// [in] input - Pointer to encrypted crypto unit
// [in] output - Pointer or handle to receive decrypted crypto unit
// [in] length - Length of crypto unit
// [in] key - ID of key to use for decryption
// [in] dts - Decode timestamp, 90 KHz clock
// [in] pts - Presentation timestamp, 90 KHz clock
// [in] au_end - Indicates end of Access Unit (last CU in frame)
//
// Returns:
// - WV_Status_OK: Decryption succeeded
// - WV_Status_Warning_Need_Key: Indicates key not yet available, will
// be retried
// - Error code indicating problem. Causes playback to halt.
//
typedef WVStatus (*WVDecryptCallback)(WVEsSelector es_type, void* input, void* output, size_t length,
int key, unsigned long long dts, unsigned long long pts, bool au_end);
enum WVDecryptCallbackMode {
WVDecryptCallbackMode_MultiCU = 0, // WVDecryptCallback called repeatedly until buffer exhausted
WVDecryptCallbackMode_SingleCU = 1, // WVDecryptCallback called once
WVDecryptCallbackMode_WholeAU = 2, // WVDecryptCallback called repeatedly until AU complete
};
class WVCallbacks {
public:
WVCallbacks() :
pushData(NULL),
response(NULL),
allocBuffer(NULL),
freeBuffer(NULL),
getDeviceID(NULL),
getKeyboxPath(NULL),
decrypt(NULL),
decryptMode(WVDecryptCallbackMode_MultiCU),
socketInfo(NULL)
{}
struct WVCallbacks {
void (*pushData)(unsigned short port, void *buffer, size_t length);
void (*response)(WVSession *session, const std::string &response);
void *(*allocBuffer)(size_t);
@@ -148,12 +110,15 @@ struct WVCallbacks {
int (*getDeviceID)(char *buffer, size_t size);
int (*getKeyboxPath)(char* path, size_t size);
WVDecryptCallback decrypt;
WVDecryptCallbackMode decryptMode;
// publish info about descriptors used for streaming for accounting purposes
WVSocketInfoCallback socketInfo;
};
//
// METHOD: WV_Initialize
//
@@ -433,16 +398,16 @@ WV_CheckBandwidth(const std::string &url, unsigned long *bandwidth, const WVProx
//This form is deprecated and may be removed in a future release
CLIENT_API WVStatus
WV_Setup(WVSession *&session, const std::string &url,
const std::string &transport, WVCredentials &credentials,
WVOutputFormat outputFormat = WV_OutputFormat_PS,
unsigned long bufferSize = 10 * 1024 * 1024, void *context = NULL);
const std::string &transport, WVCredentials &credentials,
WVOutputFormat outputFormat = WV_OutputFormat_PS,
unsigned long bufferSize = 10 * 1024 * 1024, void *context = NULL);
// Setup using a proxy
CLIENT_API WVStatus
WV_Setup(WVSession *&session, const std::string &url,
const std::string &transport, WVCredentials &credentials,
WVProxySettings &proxy, WVOutputFormat outputFormat = WV_OutputFormat_PS,
unsigned long bufferSize = 10 * 1024 * 1024, void *context = NULL);
const std::string &transport, WVCredentials &credentials,
WVProxySettings &proxy, WVOutputFormat outputFormat = WV_OutputFormat_PS,
unsigned long bufferSize = 10 * 1024 * 1024, void *context = NULL);
//
// An alternate form of WV_Setup that receives data from a file source instead of accessing
@@ -578,12 +543,20 @@ WV_Teardown(WVSession *&session);
// version. This is needed since neither absolute time nor zero time
// are appropriate for this case.
//
// [in] audioTrack - The ID of the audio track to be used. This value can be
// from the audio track dictionaries obtained via WV_Info_GetAudioTracks.
// This value is optional. If UNSPECIFIED_TRACK_ID is used, the default
// audio track, which is the first encoded into the media package, or
// the last selected audio track is used.
//
//
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
// indicating the specific error.
//
CLIENT_API WVStatus
WV_Play(WVSession *session, float scale_requested, float *scale_used, const std::string &range);
WV_Play(WVSession *session, float scale_requested, float *scale_used,
const std::string &range, WVUnsignedInt audioTrack = UNSPECIFIED_TRACK_ID);
//
// METHOD: WV_Pause
@@ -715,7 +688,6 @@ WV_GetData(WVSession *session, unsigned char *buffer, size_t request_size,
// This method is used when the client chooses to receive elementary stream data directly via
// function call using a pull data model. This method always returns data corresponding to
// at most one single access unit.
//
// Parameters:
// [in] session - The session from which data is requested
@@ -729,8 +701,6 @@ WV_GetData(WVSession *session, unsigned char *buffer, size_t request_size,
//
// [out] return_size - On return, set to the number of bytes written into the buffer
//
// [out] au_start - On return, indicates whether the data belongs to the next access unit.
//
// [out] dts - On return, set to MPEG-2 access unit decoding timestamp (DTS)
//
// [out] pts - On return, set to MPEG-2 access unit presentation timestamp (PTS)
@@ -738,6 +708,8 @@ WV_GetData(WVSession *session, unsigned char *buffer, size_t request_size,
// [out] sync_frame - On return, indicates whether the data belongs to a sync frame
// (video key frame, or audio frame).
//
// [out] au_end - On return, indicates whether the data belongs to the end of the access unit.
//
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
// indicating the specific error.
@@ -745,7 +717,33 @@ WV_GetData(WVSession *session, unsigned char *buffer, size_t request_size,
CLIENT_API WVStatus
WV_GetEsData(WVSession *session, WVEsSelector es_selector,
unsigned char *buffer, size_t request_size, size_t& return_size,
bool& au_start, unsigned long long& dts, unsigned long long& pts, bool& sync_frame);
unsigned long long& dts, unsigned long long& pts, bool& sync_frame, bool& au_end);
//
// METHOD: WV_GetNextEsDataBufferSize
//
// This method returns the optimal size of the buffer size that should be used in the next
// call to WV_GetEsData. Calculation is dependent on whether a decryption callback is used
// and if so, the decrypt callback mode (WVDecryptCallbackMode), returning the total size of
// remaining crypto units in the current access unit (no decrypt callback or
// WVDecryptCallbackMode_MultiCU specified), the size of the next crypto unit
// (decrypt callback and WVDecryptCallbackMode_SingleCU specified), or the size of the next
// access unit (decrypt callback and WVDecryptCallbackMode_WholeAU specified)
//
// Parameters:
// [in] session - The session from which data is requested
//
// [in] es_selector - Selector specifying the elementary stream targetted.
//
// [out] buffer_size - The size of the buffer
//
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
// indicating the specific error.
//
CLIENT_API WVStatus
WV_GetNextEsDataBufferSize(WVSession* session, WVEsSelector es_selector, size_t &buffer_size);
//
@@ -1067,6 +1065,28 @@ CLIENT_API WVStatus
WV_Info_TimeBuffered(WVSession *session, float *secondsBuffered);
//
// METHOD: WV_Info_GetStats
//
// This method is used to query current stats from the Widevine
// adaptive client.
//
// Parameters:
// [in] session - The session to query
//
// [in,out] stats - Dictionary containing placeholders for the
// stats to be queried. On return the available
// stats will be filled in.
//
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
// indicating the specific error.
//
CLIENT_API WVStatus
WV_Info_GetStats(WVSession *session, WVDictionary& stats);
//
// METHOD: WV_Info_GetAdaptiveBitrates
//
@@ -1297,7 +1317,7 @@ WV_SkipChapters(WVSession *session, std::string currentTime, long chapters);
//
// METHOD: WV_SkipToChapter
// METHOD: WV_GoToChapter
//
// This method causes the stream to skip to a specified chapter.
//
@@ -1315,4 +1335,143 @@ WV_SkipChapters(WVSession *session, std::string currentTime, long chapters);
CLIENT_API WVStatus
WV_GoToChapter(WVSession *session, unsigned long chapterSeqNum);
//
// METHOD: WV_Info_GetVideoTracks
//
// This method populates a WVTypedValueArray containing a WVDictionary entry
// for each adaptive video track in the media. These dicionaries contain all
// the information available for the video, as well as the track ID.
//
// Parameters:
// [in] session - The session to control
//
// [out] tracks - WVTypedValueArray which on return will contain an array
// of video track info WVDictionary(s).
////
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
// indicating the specific error.
//
CLIENT_API WVStatus
WV_Info_GetVideoTracks(WVSession *session, WVTypedValueArray& tracks);
//
// METHOD: WV_Info_GetAudioTracks
//
// This method populates a WVTypedValueArray containing a WVDictionary entry
// for each separate audio track in the media. These dicionaries contain all
// the information available for the audio, as well as the track ID.
//
// Parameters:
// [in] session - The session to control
//
// [out] tracks - WVTypedValueArray which on return will contain an array
// of audio track info WVDictionary(s).
////
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
// indicating the specific error.
//
CLIENT_API WVStatus
WV_Info_GetAudioTracks(WVSession *session, WVTypedValueArray& tracks);
//
// METHOD: WV_Info_GetSubtitleTracks
//
// This method populates a WVTypedValueArray containing a WVDictionary entry
// for each separate subtitle track in the media. These dicionaries contain all
// the information available for subtitle.
//
// NOTE: Subtitle tracks cannot be selected. They are meant to be rendered by
// the device media player.
//
// Parameters:
// [in] session - The session to control
//
// [out] tracks - WVTypedValueArray which on return will contain an array
// of subtile track info WVDictionary(s).
////
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
// indicating the specific error.
//
CLIENT_API WVStatus
WV_Info_GetSubtitleTracks(WVSession *session, WVTypedValueArray& tracks);
//
// METHOD: WV_Info_GetCurrentVideoTrack
//
// This method populates a WVDicionary all the information available for the
// current adaptive video track, as well as its track ID.
//
// Parameters:
// [in] session - The session to control
//
// [out] track - WVDictionary which on return will contain the information
// available for the current adaptive video track
////
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
// indicating the specific error.
//
CLIENT_API WVStatus
WV_Info_GetCurrentVideoTrack(WVSession *session, WVDictionary& track);
//
// METHOD: WV_Info_GetCurrentAudioTrack
//
// This method populates a WVDicionary all the information available for the
// current separate audio track, as well as its track ID.
//
// Parameters:
// [in] session - The session to control
//
// [out] track - WVDictionary which on return will contain the information
// available for the current adaptive video track
////
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
// indicating the specific error. This function returns the status
// WV_Status_Warning_Not_Available if separate audio is not available.
//
CLIENT_API WVStatus
WV_Info_GetCurrentAudioTrack(WVSession *session, WVDictionary& track);
//
// METHOD: WV_SelectTrack
//
// This method is used to explicitly select an adaptive video track or
// separate audio track.
//
// Parameters:
// [in] session - The session to control
//
// [out] trackId - The track ID for the track to be selected.
// If an adaptive video track ID is specified, then a
// video track change will be effected. Specifying
// UNSPECIFIED_TRACK_ID will resume normal adaptive
// video behavior.
// If a separate audio track ID is specified, then
// an audio track change will be effected.
////
// Returns:
// WV_Status_OK on success, otherwise one of the WVStatus values
// indicating the specific error.
//
CLIENT_API WVStatus WV_SelectTrack(WVSession* session, WVUnsignedInt trackId);
#endif // __WV_STREAM_CONTROL_API_H__