1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_UTIL_H_
6 #define MEDIA_BLINK_WEBMEDIAPLAYER_UTIL_H_
8 #include "base/time/time.h"
9 #include "media/base/audio_renderer_sink.h"
10 #include "media/base/eme_constants.h"
11 #include "media/base/media_export.h"
12 #include "media/base/pipeline_status.h"
13 #include "media/base/ranges.h"
14 #include "third_party/WebKit/public/platform/WebCallbacks.h"
15 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h"
16 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
17 #include "third_party/WebKit/public/platform/WebSetSinkIdError.h"
18 #include "third_party/WebKit/public/platform/WebTimeRange.h"
23 // Platform independent method for converting and rounding floating point
24 // seconds to an int64 timestamp.
26 // Refer to https://bugs.webkit.org/show_bug.cgi?id=52697 for details.
27 base::TimeDelta MEDIA_EXPORT
ConvertSecondsToTimestamp(double seconds
);
29 blink::WebTimeRanges MEDIA_EXPORT
ConvertToWebTimeRanges(
30 const Ranges
<base::TimeDelta
>& ranges
);
32 blink::WebMediaPlayer::NetworkState MEDIA_EXPORT
PipelineErrorToNetworkState(
33 PipelineStatus error
);
35 // Report various metrics to UMA and RAPPOR.
36 void MEDIA_EXPORT
ReportMetrics(blink::WebMediaPlayer::LoadType load_type
,
38 const GURL
& origin_url
);
40 // Record a RAPPOR metric for the origin of an HLS playback.
41 void MEDIA_EXPORT
RecordOriginOfHLSPlayback(const GURL
& origin_url
);
43 // Convert Initialization Data Types.
44 EmeInitDataType MEDIA_EXPORT
45 ConvertToEmeInitDataType(blink::WebEncryptedMediaInitDataType init_data_type
);
46 blink::WebEncryptedMediaInitDataType MEDIA_EXPORT
47 ConvertToWebInitDataType(EmeInitDataType init_data_type
);
49 typedef blink::WebCallbacks
<void, blink::WebSetSinkIdError
*> WebSetSinkIdCB
;
51 // Wraps a WebSetSinkIdCB into a media::SwitchOutputDeviceCB
52 // and binds it to the current thread
53 SwitchOutputDeviceCB MEDIA_EXPORT
54 ConvertToSwitchOutputDeviceCB(WebSetSinkIdCB
* web_callbacks
);
58 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_UTIL_H_