BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / media / base / android / demuxer_stream_player_params.cc
blob6e86a7feeb5f6352738795a6133090b3fd9bc62a
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 const char* AsString(DemuxerStream::Type stream_type) {
33 switch (stream_type) {
34 case DemuxerStream::UNKNOWN:
35 return "UNKNOWN";
36 case DemuxerStream::AUDIO:
37 return "AUDIO";
38 case DemuxerStream::VIDEO:
39 return "VIDEO";
40 case DemuxerStream::TEXT:
41 return "TEXT";
42 case DemuxerStream::NUM_TYPES:
43 return "NUM_TYPES";
45 NOTREACHED();
46 return nullptr; // crash early
49 #undef RETURN_STRING
50 #define RETURN_STRING(x) \
51 case x: \
52 return #x;
54 const char* AsString(AudioCodec codec) {
55 switch (codec) {
56 RETURN_STRING(kUnknownAudioCodec);
57 RETURN_STRING(kCodecAAC);
58 RETURN_STRING(kCodecMP3);
59 RETURN_STRING(kCodecPCM);
60 RETURN_STRING(kCodecVorbis);
61 RETURN_STRING(kCodecFLAC);
62 RETURN_STRING(kCodecAMR_NB);
63 RETURN_STRING(kCodecAMR_WB);
64 RETURN_STRING(kCodecPCM_MULAW);
65 RETURN_STRING(kCodecGSM_MS);
66 RETURN_STRING(kCodecPCM_S16BE);
67 RETURN_STRING(kCodecPCM_S24BE);
68 RETURN_STRING(kCodecOpus);
69 RETURN_STRING(kCodecPCM_ALAW);
70 RETURN_STRING(kCodecALAC);
72 NOTREACHED();
73 return nullptr; // crash early
76 const char* AsString(VideoCodec codec) {
77 switch (codec) {
78 RETURN_STRING(kUnknownVideoCodec);
79 RETURN_STRING(kCodecH264);
80 RETURN_STRING(kCodecHEVC);
81 RETURN_STRING(kCodecVC1);
82 RETURN_STRING(kCodecMPEG2);
83 RETURN_STRING(kCodecMPEG4);
84 RETURN_STRING(kCodecTheora);
85 RETURN_STRING(kCodecVP8);
86 RETURN_STRING(kCodecVP9);
88 NOTREACHED();
89 return nullptr; // crash early
92 const char* AsString(DemuxerStream::Status status) {
93 switch (status) {
94 case DemuxerStream::kOk:
95 return "kOk";
96 case DemuxerStream::kAborted:
97 return "kAborted";
98 case DemuxerStream::kConfigChanged:
99 return "kConfigChanged";
101 NOTREACHED();
102 return nullptr; // crash early
105 #undef RETURN_STRING
107 } // namespace (anonymous)
109 } // namespace media
111 std::ostream& operator<<(std::ostream& os, media::DemuxerStream::Type type) {
112 os << media::AsString(type);
113 return os;
116 std::ostream& operator<<(std::ostream& os, const media::AccessUnit& au) {
117 os << "status:" << media::AsString(au.status)
118 << (au.is_end_of_stream ? " EOS" : "")
119 << (au.is_key_frame ? " KEY_FRAME" : "") << " pts:" << au.timestamp
120 << " size:" << au.data.size();
121 return os;
124 std::ostream& operator<<(std::ostream& os, const media::DemuxerConfigs& conf) {
125 os << "duration:" << conf.duration;
127 if (conf.audio_codec == media::kUnknownAudioCodec &&
128 conf.video_codec == media::kUnknownVideoCodec) {
129 os << " no audio, no video";
130 return os;
133 if (conf.audio_codec != media::kUnknownAudioCodec) {
134 os << " audio:" << media::AsString(conf.audio_codec)
135 << " channels:" << conf.audio_channels
136 << " rate:" << conf.audio_sampling_rate
137 << (conf.is_audio_encrypted ? " encrypted" : "")
138 << " delay (ns):" << conf.audio_codec_delay_ns
139 << " preroll (ns):" << conf.audio_seek_preroll_ns;
141 if (!conf.audio_extra_data.empty()) {
142 os << " extra:{" << std::hex;
143 for (uint8 byte : conf.audio_extra_data)
144 os << " " << std::setfill('0') << std::setw(2) << (int)byte;
145 os << "}" << std::dec;
149 if (conf.video_codec != media::kUnknownVideoCodec) {
150 os << " video:" << media::AsString(conf.video_codec) << " "
151 << conf.video_size.width() << "x" << conf.video_size.height()
152 << (conf.is_video_encrypted ? " encrypted" : "");
155 return os;