OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/base/android/demuxer_stream_player_params.h" | 5 #include "media/base/android/demuxer_stream_player_params.h" |
6 | 6 |
7 namespace media { | 7 namespace media { |
8 | 8 |
9 DemuxerConfigs::DemuxerConfigs() | 9 DemuxerConfigs::DemuxerConfigs() |
10 : audio_codec(kUnknownAudioCodec), | 10 : audio_codec(kUnknownAudioCodec), |
11 audio_channels(0), | 11 audio_channels(0), |
12 audio_sampling_rate(0), | 12 audio_sampling_rate(0), |
13 is_audio_encrypted(false), | 13 is_audio_encrypted(false), |
14 audio_codec_delay_ns(-1), | 14 audio_codec_delay_ns(-1), |
15 audio_seek_preroll_ns(-1), | 15 audio_seek_preroll_ns(-1), |
16 video_codec(kUnknownVideoCodec), | 16 video_codec(kUnknownVideoCodec), |
17 is_video_encrypted(false) {} | 17 is_video_encrypted(false) {} |
18 | 18 |
19 DemuxerConfigs::~DemuxerConfigs() {} | 19 DemuxerConfigs::~DemuxerConfigs() {} |
20 | 20 |
21 AccessUnit::AccessUnit() : is_end_of_stream(false), is_key_frame(false) {} | 21 AccessUnit::AccessUnit() : is_end_of_stream(false), is_key_frame(false) {} |
22 | 22 |
23 AccessUnit::~AccessUnit() {} | 23 AccessUnit::~AccessUnit() {} |
24 | 24 |
25 DemuxerData::DemuxerData() : type(DemuxerStream::UNKNOWN) {} | 25 DemuxerData::DemuxerData() : type(DemuxerStream::UNKNOWN) {} |
26 | 26 |
27 DemuxerData::~DemuxerData() {} | 27 DemuxerData::~DemuxerData() {} |
28 | 28 |
| 29 namespace { |
| 30 |
| 31 #undef RETURN_STRING |
| 32 #define RETURN_STRING(x) \ |
| 33 case x: \ |
| 34 return #x; |
| 35 |
| 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); |
| 53 } |
| 54 NOTREACHED(); |
| 55 return nullptr; // crash early |
| 56 } |
| 57 |
| 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); |
| 68 } |
| 69 NOTREACHED(); |
| 70 return nullptr; // crash early |
| 71 } |
| 72 |
| 73 #undef RETURN_STRING |
| 74 |
| 75 } // namespace (anonymous) |
| 76 |
29 } // namespace media | 77 } // namespace media |
| 78 |
| 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; |
| 84 } |
| 85 |
| 86 std::ostream& operator<<(std::ostream& os, const media::DemuxerConfigs& conf) { |
| 87 os << "duration:" << conf.duration; |
| 88 |
| 89 if (conf.audio_codec == media::kUnknownAudioCodec && |
| 90 conf.video_codec == media::kUnknownVideoCodec) { |
| 91 os << " no audio, no video"; |
| 92 return os; |
| 93 } |
| 94 |
| 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" : ""); |
| 100 } |
| 101 |
| 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" : ""); |
| 106 } |
| 107 |
| 108 return os; |
| 109 } |
OLD | NEW |