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"
10 DemuxerConfigs::DemuxerConfigs()
11 : audio_codec(kUnknownAudioCodec
),
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() {}
32 const char* AsString(DemuxerStream::Type stream_type
) {
33 switch (stream_type
) {
34 case DemuxerStream::UNKNOWN
:
36 case DemuxerStream::AUDIO
:
38 case DemuxerStream::VIDEO
:
40 case DemuxerStream::TEXT
:
42 case DemuxerStream::NUM_TYPES
:
46 return nullptr; // crash early
50 #define RETURN_STRING(x) \
54 const char* AsString(AudioCodec 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
);
73 return nullptr; // crash early
76 const char* AsString(VideoCodec 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
);
89 return nullptr; // crash early
92 const char* AsString(DemuxerStream::Status status
) {
94 case DemuxerStream::kOk
:
96 case DemuxerStream::kAborted
:
98 case DemuxerStream::kConfigChanged
:
99 return "kConfigChanged";
102 return nullptr; // crash early
107 } // namespace (anonymous)
111 std::ostream
& operator<<(std::ostream
& os
, media::DemuxerStream::Type type
) {
112 os
<< media::AsString(type
);
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();
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";
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" : "");