Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / media / base / android / demuxer_stream_player_params.cc
blob722eba540fef41f438305095a767a9ada0fc282a
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 const char* AsString(DemuxerStream::Status status) {
75 switch (status) {
76 case DemuxerStream::kOk:
77 return "kOk";
78 case DemuxerStream::kAborted:
79 return "kAborted";
80 case DemuxerStream::kConfigChanged:
81 return "kConfigChanged";
83 NOTREACHED();
84 return nullptr; // crash early
87 #undef RETURN_STRING
89 } // namespace (anonymous)
91 } // namespace media
93 std::ostream& operator<<(std::ostream& os, const media::AccessUnit& au) {
94 os << "status:" << media::AsString(au.status)
95 << (au.is_end_of_stream ? " EOS" : "")
96 << (au.is_key_frame ? " KEY_FRAME" : "") << " pts:" << au.timestamp
97 << " size:" << au.data.size();
98 return os;
101 std::ostream& operator<<(std::ostream& os, const media::DemuxerConfigs& conf) {
102 os << "duration:" << conf.duration;
104 if (conf.audio_codec == media::kUnknownAudioCodec &&
105 conf.video_codec == media::kUnknownVideoCodec) {
106 os << " no audio, no video";
107 return os;
110 if (conf.audio_codec != media::kUnknownAudioCodec) {
111 os << " audio:" << media::AsString(conf.audio_codec)
112 << " channels:" << conf.audio_channels
113 << " rate:" << conf.audio_sampling_rate
114 << (conf.is_audio_encrypted ? " encrypted" : "")
115 << " delay (ns):" << conf.audio_codec_delay_ns
116 << " preroll (ns):" << conf.audio_seek_preroll_ns;
118 if (!conf.audio_extra_data.empty()) {
119 os << " extra:{" << std::hex;
120 for (uint8 byte : conf.audio_extra_data)
121 os << " " << std::setfill('0') << std::setw(2) << (int)byte;
122 os << "}" << std::dec;
126 if (conf.video_codec != media::kUnknownVideoCodec) {
127 os << " video:" << media::AsString(conf.video_codec) << " "
128 << conf.video_size.width() << "x" << conf.video_size.height()
129 << (conf.is_video_encrypted ? " encrypted" : "");
132 return os;