Roll src/third_party/WebKit d10c917:a1123a1 (svn 198729:198730)
[chromium-blink-merge.git] / media / base / android / demuxer_stream_player_params.cc
blobae656f8911c3d80c5d8d5e86c6af4df0973f9615
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"
7 namespace media {
9 DemuxerConfigs::DemuxerConfigs()
10 : audio_codec(kUnknownAudioCodec),
11 audio_channels(0),
12 audio_sampling_rate(0),
13 is_audio_encrypted(false),
14 audio_codec_delay_ns(-1),
15 audio_seek_preroll_ns(-1),
16 video_codec(kUnknownVideoCodec),
17 is_video_encrypted(false) {}
19 DemuxerConfigs::~DemuxerConfigs() {}
21 AccessUnit::AccessUnit() : is_end_of_stream(false), is_key_frame(false) {}
23 AccessUnit::~AccessUnit() {}
25 DemuxerData::DemuxerData() : type(DemuxerStream::UNKNOWN) {}
27 DemuxerData::~DemuxerData() {}
29 namespace {
31 #undef RETURN_STRING
32 #define RETURN_STRING(x) \
33 case x: \
34 return #x;
36 const char* AsString(AudioCodec codec) {
37 switch (codec) {
38 RETURN_STRING(kUnknownAudioCodec);
39 RETURN_STRING(kCodecAAC);
40 RETURN_STRING(kCodecMP3);
41 RETURN_STRING(kCodecPCM);
42 RETURN_STRING(kCodecVorbis);
43 RETURN_STRING(kCodecFLAC);
44 RETURN_STRING(kCodecAMR_NB);
45 RETURN_STRING(kCodecAMR_WB);
46 RETURN_STRING(kCodecPCM_MULAW);
47 RETURN_STRING(kCodecGSM_MS);
48 RETURN_STRING(kCodecPCM_S16BE);
49 RETURN_STRING(kCodecPCM_S24BE);
50 RETURN_STRING(kCodecOpus);
51 RETURN_STRING(kCodecPCM_ALAW);
52 RETURN_STRING(kCodecALAC);
54 NOTREACHED();
55 return nullptr; // crash early
58 const char* AsString(VideoCodec codec) {
59 switch (codec) {
60 RETURN_STRING(kUnknownVideoCodec);
61 RETURN_STRING(kCodecH264);
62 RETURN_STRING(kCodecVC1);
63 RETURN_STRING(kCodecMPEG2);
64 RETURN_STRING(kCodecMPEG4);
65 RETURN_STRING(kCodecTheora);
66 RETURN_STRING(kCodecVP8);
67 RETURN_STRING(kCodecVP9);
69 NOTREACHED();
70 return nullptr; // crash early
73 #undef RETURN_STRING
75 } // namespace (anonymous)
77 } // namespace media
79 std::ostream& operator<<(std::ostream& os, const media::AccessUnit& au) {
80 os << "status:" << au.status << (au.is_end_of_stream ? " EOS" : "")
81 << (au.is_key_frame ? " KEY_FRAME" : "") << " pts:" << au.timestamp
82 << " size:" << au.data.size();
83 return os;
86 std::ostream& operator<<(std::ostream& os, const media::DemuxerConfigs& conf) {
87 os << "duration:" << conf.duration;
89 if (conf.audio_codec == media::kUnknownAudioCodec &&
90 conf.video_codec == media::kUnknownVideoCodec) {
91 os << " no audio, no video";
92 return os;
95 if (conf.audio_codec != media::kUnknownAudioCodec) {
96 os << " audio:" << media::AsString(conf.audio_codec)
97 << " channels:" << conf.audio_channels
98 << " rate:" << conf.audio_sampling_rate
99 << (conf.is_audio_encrypted ? " encrypted" : "");
102 if (conf.video_codec != media::kUnknownVideoCodec) {
103 os << " video:" << media::AsString(conf.video_codec) << " "
104 << conf.video_size.width() << "x" << conf.video_size.height()
105 << (conf.is_video_encrypted ? " encrypted" : "");
108 return os;