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() {}
33 #define RETURN_STRING(x) \
37 const char* AsString(AudioCodec 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
);
56 return nullptr; // crash early
59 const char* AsString(VideoCodec 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
);
71 return nullptr; // crash early
74 const char* AsString(DemuxerStream::Status status
) {
76 case DemuxerStream::kOk
:
78 case DemuxerStream::kAborted
:
80 case DemuxerStream::kConfigChanged
:
81 return "kConfigChanged";
84 return nullptr; // crash early
89 } // namespace (anonymous)
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();
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";
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" : "");