Extension syncing: Introduce a NeedsSync pref
[chromium-blink-merge.git] / media / base / android / demuxer_stream_player_params.cc
blob9bf443d1b8a588f60355a2f2dda1712e625dcccf
1 // Copyright (c) 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 #include "media/base/android/demuxer_stream_player_params.h"
6 #include <iomanip>
8 namespace media {
10 DemuxerConfigs::DemuxerConfigs()
11 : audio_codec(kUnknownAudioCodec),
12 audio_channels(0),
13 audio_sampling_rate(0),
14 is_audio_encrypted(false),
15 audio_codec_delay_ns(-1),
16 audio_seek_preroll_ns(-1),
17 video_codec(kUnknownVideoCodec),
18 is_video_encrypted(false) {}
20 DemuxerConfigs::~DemuxerConfigs() {}
22 AccessUnit::AccessUnit() : is_end_of_stream(false), is_key_frame(false) {}
24 AccessUnit::~AccessUnit() {}
26 DemuxerData::DemuxerData() : type(DemuxerStream::UNKNOWN) {}
28 DemuxerData::~DemuxerData() {}
30 namespace {
32 #undef RETURN_STRING
33 #define RETURN_STRING(x) \
34 case x: \
35 return #x;
37 const char* AsString(AudioCodec codec) {
38 switch (codec) {
39 RETURN_STRING(kUnknownAudioCodec);
40 RETURN_STRING(kCodecAAC);
41 RETURN_STRING(kCodecMP3);
42 RETURN_STRING(kCodecPCM);
43 RETURN_STRING(kCodecVorbis);
44 RETURN_STRING(kCodecFLAC);
45 RETURN_STRING(kCodecAMR_NB);
46 RETURN_STRING(kCodecAMR_WB);
47 RETURN_STRING(kCodecPCM_MULAW);
48 RETURN_STRING(kCodecGSM_MS);
49 RETURN_STRING(kCodecPCM_S16BE);
50 RETURN_STRING(kCodecPCM_S24BE);
51 RETURN_STRING(kCodecOpus);
52 RETURN_STRING(kCodecPCM_ALAW);
53 RETURN_STRING(kCodecALAC);
55 NOTREACHED();
56 return nullptr; // crash early
59 const char* AsString(VideoCodec codec) {
60 switch (codec) {
61 RETURN_STRING(kUnknownVideoCodec);
62 RETURN_STRING(kCodecH264);
63 RETURN_STRING(kCodecVC1);
64 RETURN_STRING(kCodecMPEG2);
65 RETURN_STRING(kCodecMPEG4);
66 RETURN_STRING(kCodecTheora);
67 RETURN_STRING(kCodecVP8);
68 RETURN_STRING(kCodecVP9);
70 NOTREACHED();
71 return nullptr; // crash early
74 #undef RETURN_STRING
76 } // namespace (anonymous)
78 } // namespace media
80 std::ostream& operator<<(std::ostream& os, const media::AccessUnit& au) {
81 os << "status:" << au.status << (au.is_end_of_stream ? " EOS" : "")
82 << (au.is_key_frame ? " KEY_FRAME" : "") << " pts:" << au.timestamp
83 << " size:" << au.data.size();
84 return os;
87 std::ostream& operator<<(std::ostream& os, const media::DemuxerConfigs& conf) {
88 os << "duration:" << conf.duration;
90 if (conf.audio_codec == media::kUnknownAudioCodec &&
91 conf.video_codec == media::kUnknownVideoCodec) {
92 os << " no audio, no video";
93 return os;
96 if (conf.audio_codec != media::kUnknownAudioCodec) {
97 os << " audio:" << media::AsString(conf.audio_codec)
98 << " channels:" << conf.audio_channels
99 << " rate:" << conf.audio_sampling_rate
100 << (conf.is_audio_encrypted ? " encrypted" : "")
101 << " delay (ns):" << conf.audio_codec_delay_ns
102 << " preroll (ns):" << conf.audio_seek_preroll_ns;
104 if (!conf.audio_extra_data.empty()) {
105 os << " extra:{" << std::hex;
106 for (uint8 byte : conf.audio_extra_data)
107 os << " " << std::setfill('0') << std::setw(2) << (int)byte;
108 os << "}" << std::dec;
112 if (conf.video_codec != media::kUnknownVideoCodec) {
113 os << " video:" << media::AsString(conf.video_codec) << " "
114 << conf.video_size.width() << "x" << conf.video_size.height()
115 << (conf.is_video_encrypted ? " encrypted" : "");
118 return os;