OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #include <iostream> |
| 6 |
| 7 #include "services/media/framework/formatting.h" |
| 8 |
| 9 namespace mojo { |
| 10 namespace media { |
| 11 |
| 12 int ostream_indent_index() { |
| 13 static int i = std::ios_base::xalloc(); |
| 14 return i; |
| 15 } |
| 16 |
| 17 std::ostream& operator<<(std::ostream& os, Result value) { |
| 18 switch (value) { |
| 19 case Result::kOk: |
| 20 return os << "kOk"; |
| 21 case Result::kUnknownError: |
| 22 return os << "kUnknownError"; |
| 23 case Result::kInternalError: |
| 24 return os << "kInternalError"; |
| 25 case Result::kUnsupportedOperation: |
| 26 return os << "kUnsupportedOperation"; |
| 27 case Result::kInvalidArgument: |
| 28 return os << "kInvalidArgument"; |
| 29 case Result::kNotFound: |
| 30 return os << "kNotFound"; |
| 31 } |
| 32 } |
| 33 |
| 34 std::ostream& operator<<(std::ostream& os, Demand value) { |
| 35 switch (value) { |
| 36 case Demand::kNegative: |
| 37 return os << "kNegative"; |
| 38 case Demand::kNeutral: |
| 39 return os << "kNeutral"; |
| 40 case Demand::kPositive: |
| 41 return os << "kPositive"; |
| 42 } |
| 43 } |
| 44 |
| 45 std::ostream& operator<<(std::ostream& os, const PacketPtr& value) { |
| 46 if (!value) { |
| 47 return os << "<nullptr>"; |
| 48 } |
| 49 |
| 50 os << "&" << std::hex << uint64_t(value.get()) << std::dec; |
| 51 os << "/pts:" << value->presentation_time(); |
| 52 os << "/dur:" << value->duration(); |
| 53 os << "/eos:" << (value->end_of_stream() ? "t" : "f"); |
| 54 os << "/size:" << value->size(); |
| 55 os << "/payload:" << std::hex << uint64_t(value->payload()) << std::dec; |
| 56 return os; |
| 57 } |
| 58 |
| 59 std::ostream& operator<<(std::ostream& os, const StreamTypePtr& value) { |
| 60 if (!value) { |
| 61 return os << "<nullptr>" << std::endl; |
| 62 } else { |
| 63 os << std::endl; |
| 64 } |
| 65 |
| 66 os << indent; |
| 67 os << begl << "Scheme scheme(): " << value->scheme() << std::endl; |
| 68 switch (value->scheme()) { |
| 69 case StreamType::Scheme::kMultiplexed: |
| 70 os << begl << "StreamTypePtr multiplex_type: " |
| 71 << value->multiplexed()->multiplex_type(); |
| 72 os << begl << "StreamTypesPtr substream_types: " |
| 73 << value->multiplexed()->substream_types(); |
| 74 break; |
| 75 case StreamType::Scheme::kLpcm: |
| 76 os << begl << "SampleFormat sample_format: " |
| 77 << value->lpcm()->sample_format() << std::endl; |
| 78 os << begl << "uint32_t channels: " |
| 79 << value->lpcm()->channels() << std::endl; |
| 80 os << begl << "uint32_t frames_per_second: " |
| 81 << value->lpcm()->frames_per_second() << std::endl; |
| 82 break; |
| 83 case StreamType::Scheme::kCompressedAudio: |
| 84 os << begl << "AudioEncoding encoding: " |
| 85 << value->compressed_audio()->encoding() << std::endl; |
| 86 os << begl << "SampleFormat sample_format: " |
| 87 << value->compressed_audio()->sample_format() << std::endl; |
| 88 os << begl << "uint32_t channels: " |
| 89 << value->compressed_audio()->channels() << std::endl; |
| 90 os << begl << "uint32_t frames_per_second: " |
| 91 << value->compressed_audio()->frames_per_second() << std::endl; |
| 92 os << begl << "BytesPtr encoding_details: " |
| 93 << value->compressed_audio()->encoding_details() << std::endl; |
| 94 break; |
| 95 case StreamType::Scheme::kVideo: |
| 96 os << begl << "VideoEncoding encoding: " |
| 97 << value->video()->encoding() << std::endl; |
| 98 os << begl << "VideoProfile profile: " |
| 99 << value->video()->profile() << std::endl; |
| 100 os << begl << "PixelFormat pixel_format: " |
| 101 << value->video()->pixel_format() << std::endl; |
| 102 os << begl << "ColorSpace color_space: " |
| 103 << value->video()->color_space() << std::endl; |
| 104 os << begl << "uint32_t width: " |
| 105 << value->video()->width() << std::endl; |
| 106 os << begl << "uint32_t height: " |
| 107 << value->video()->height() << std::endl; |
| 108 os << begl << "uint32_t coded_width: " |
| 109 << value->video()->coded_width() << std::endl; |
| 110 os << begl << "uint32_t coded_height: " |
| 111 << value->video()->coded_height() << std::endl; |
| 112 os << begl << "BytesPtr encoding_details: " |
| 113 << value->video()->encoding_details() << std::endl; |
| 114 break; |
| 115 default: |
| 116 break; |
| 117 } |
| 118 |
| 119 return os << outdent; |
| 120 } |
| 121 |
| 122 std::ostream& operator<<(std::ostream& os, const StreamTypeSetPtr& value) { |
| 123 if (!value) { |
| 124 return os << "<nullptr>" << std::endl; |
| 125 } else { |
| 126 os << std::endl; |
| 127 } |
| 128 |
| 129 os << indent; |
| 130 os << begl << "Scheme scheme(): " << value->scheme() << std::endl; |
| 131 switch (value->scheme()) { |
| 132 case StreamType::Scheme::kMultiplexed: |
| 133 os << begl << "StreamTypeSetPtr multiplex_type_set: " |
| 134 << value->multiplexed()->multiplex_type_set(); |
| 135 os << begl << "StreamTypeSetsPtr substream_type_sets: " |
| 136 << value->multiplexed()->substream_type_sets(); |
| 137 break; |
| 138 case StreamType::Scheme::kLpcm: |
| 139 os << begl << "SampleFormat sample_format: " |
| 140 << value->lpcm()->sample_format() << std::endl; |
| 141 os << begl << "Range<uint32_t> channels: " |
| 142 << value->lpcm()->channels() << std::endl; |
| 143 os << begl << "Range<uint32_t> frames_per_second: " |
| 144 << value->lpcm()->frames_per_second() << std::endl; |
| 145 break; |
| 146 case StreamType::Scheme::kCompressedAudio: |
| 147 os << begl << "AudioEncoding encoding: " |
| 148 << value->compressed_audio()->encoding() << std::endl; |
| 149 os << begl << "SampleFormat sample_format: " |
| 150 << value->compressed_audio()->sample_format() << std::endl; |
| 151 os << begl << "Range<uint32_t> channels: " |
| 152 << value->compressed_audio()->channels() << std::endl; |
| 153 os << begl << "Range<uint32_t> frames_per_second: " |
| 154 << value->compressed_audio()->frames_per_second() << std::endl; |
| 155 break; |
| 156 case StreamType::Scheme::kVideo: |
| 157 os << begl << "VideoEncoding encoding: " |
| 158 << value->video()->encoding() << std::endl; |
| 159 os << begl << "Range<uint32_t> width: " |
| 160 << value->video()->width() << std::endl; |
| 161 os << begl << "Range<uint32_t> height: " |
| 162 << value->video()->height() << std::endl; |
| 163 break; |
| 164 default: |
| 165 break; |
| 166 } |
| 167 |
| 168 return os << outdent; |
| 169 } |
| 170 |
| 171 std::ostream& operator<<(std::ostream& os, const StreamTypesPtr& value) { |
| 172 if (!value) { |
| 173 return os << "<nullptr>" << std::endl; |
| 174 } else if (value->size() == 0) { |
| 175 return os << "<empty>" << std::endl; |
| 176 } else { |
| 177 os << std::endl; |
| 178 } |
| 179 |
| 180 int index = 0; |
| 181 for (const StreamTypePtr& element : *value) { |
| 182 os << "[" << index++ << "]: " << element; |
| 183 } |
| 184 |
| 185 return os; |
| 186 } |
| 187 |
| 188 std::ostream& operator<<(std::ostream& os, const StreamTypeSetsPtr& value) { |
| 189 if (!value) { |
| 190 return os << "<nullptr>" << std::endl; |
| 191 } else if (value->size() == 0) { |
| 192 return os << "<empty>" << std::endl; |
| 193 } else { |
| 194 os << std::endl; |
| 195 } |
| 196 |
| 197 int index = 0; |
| 198 for (const StreamTypeSetPtr& element : *value) { |
| 199 os << "[" << index++ << "]: " << element; |
| 200 } |
| 201 |
| 202 return os; |
| 203 } |
| 204 |
| 205 std::ostream& operator<<(std::ostream& os, StreamType::Scheme value) { |
| 206 switch (value) { |
| 207 case StreamType::Scheme::kUnknown: |
| 208 return os << "kUnknown"; |
| 209 case StreamType::Scheme::kNone: |
| 210 return os << "kNone"; |
| 211 case StreamType::Scheme::kAnyElementary: |
| 212 return os << "kAnyElementary"; |
| 213 case StreamType::Scheme::kAnyAudio: |
| 214 return os << "kAnyAudio"; |
| 215 case StreamType::Scheme::kAnyVideo: |
| 216 return os << "kAnyVideo"; |
| 217 case StreamType::Scheme::kAnySubpicture: |
| 218 return os << "kAnySubpicture"; |
| 219 case StreamType::Scheme::kAnyText: |
| 220 return os << "kAnyText"; |
| 221 case StreamType::Scheme::kAnyMultiplexed: |
| 222 return os << "kAnyMultiplexed"; |
| 223 case StreamType::Scheme::kAny: |
| 224 return os << "kAny"; |
| 225 case StreamType::Scheme::kMultiplexed: |
| 226 return os << "kMultiplexed"; |
| 227 case StreamType::Scheme::kLpcm: |
| 228 return os << "kLpcm"; |
| 229 case StreamType::Scheme::kCompressedAudio: |
| 230 return os << "kCompressedAudio"; |
| 231 case StreamType::Scheme::kVideo: |
| 232 return os << "kVideo"; |
| 233 } |
| 234 } |
| 235 |
| 236 std::ostream& operator<<(std::ostream& os, LpcmStreamType::SampleFormat value) { |
| 237 switch (value) { |
| 238 case LpcmStreamType::SampleFormat::kUnknown: |
| 239 return os << "kUnknown"; |
| 240 case LpcmStreamType::SampleFormat::kAny: |
| 241 return os << "kAny"; |
| 242 case LpcmStreamType::SampleFormat::kUnsigned8: |
| 243 return os << "kUnsigned8"; |
| 244 case LpcmStreamType::SampleFormat::kSigned16: |
| 245 return os << "kSigned16"; |
| 246 case LpcmStreamType::SampleFormat::kSigned24In32: |
| 247 return os << "kSigned24In32"; |
| 248 case LpcmStreamType::SampleFormat::kFloat: |
| 249 return os << "kFloat"; |
| 250 } |
| 251 } |
| 252 |
| 253 std::ostream& operator<<( |
| 254 std::ostream& os, |
| 255 CompressedAudioStreamType::AudioEncoding value) { |
| 256 switch (value) { |
| 257 case CompressedAudioStreamType::AudioEncoding::kUnknown: |
| 258 return os << "kUnknown"; |
| 259 case CompressedAudioStreamType::AudioEncoding::kAny: |
| 260 return os << "kAny"; |
| 261 case CompressedAudioStreamType::AudioEncoding::kVorbis: |
| 262 return os << "kVorbis"; |
| 263 } |
| 264 } |
| 265 |
| 266 std::ostream& operator<<( |
| 267 std::ostream& os, |
| 268 VideoStreamType::VideoEncoding value) { |
| 269 switch (value) { |
| 270 case VideoStreamType::VideoEncoding::kUnknown: |
| 271 return os << "kUnknown"; |
| 272 case VideoStreamType::VideoEncoding::kAny: |
| 273 return os << "kAny"; |
| 274 case VideoStreamType::VideoEncoding::kTheora: |
| 275 return os << "kTheora"; |
| 276 case VideoStreamType::VideoEncoding::kVp8: |
| 277 return os << "kVp8"; |
| 278 } |
| 279 } |
| 280 |
| 281 std::ostream& operator<<( |
| 282 std::ostream& os, |
| 283 VideoStreamType::VideoProfile value) { |
| 284 switch (value) { |
| 285 case VideoStreamType::VideoProfile::kUnknown: |
| 286 return os << "kUnknown"; |
| 287 case VideoStreamType::VideoProfile::kNotApplicable: |
| 288 return os << "kNotApplicable"; |
| 289 case VideoStreamType::VideoProfile::kH264Baseline: |
| 290 return os << "kH264Baseline"; |
| 291 case VideoStreamType::VideoProfile::kH264Main: |
| 292 return os << "kH264Main"; |
| 293 case VideoStreamType::VideoProfile::kH264Extended: |
| 294 return os << "kH264Extended"; |
| 295 case VideoStreamType::VideoProfile::kH264High: |
| 296 return os << "kH264High"; |
| 297 case VideoStreamType::VideoProfile::kH264High10: |
| 298 return os << "kH264High10"; |
| 299 case VideoStreamType::VideoProfile::kH264High422: |
| 300 return os << "kH264High422"; |
| 301 case VideoStreamType::VideoProfile::kH264High444Predictive: |
| 302 return os << "kH264High444Predictive"; |
| 303 case VideoStreamType::VideoProfile::kH264ScalableBaseline: |
| 304 return os << "kH264ScalableBaseline"; |
| 305 case VideoStreamType::VideoProfile::kH264ScalableHigh: |
| 306 return os << "kH264ScalableHigh"; |
| 307 case VideoStreamType::VideoProfile::kH264StereoHigh: |
| 308 return os << "kH264StereoHigh"; |
| 309 case VideoStreamType::VideoProfile::kH264MultiviewHigh: |
| 310 return os << "kH264MultiviewHigh"; |
| 311 } |
| 312 } |
| 313 |
| 314 std::ostream& operator<<(std::ostream& os, VideoStreamType::PixelFormat value) { |
| 315 switch (value) { |
| 316 case VideoStreamType::PixelFormat::kUnknown: |
| 317 return os << "kUnknown"; |
| 318 case VideoStreamType::PixelFormat::kI420: |
| 319 return os << "kI420"; |
| 320 case VideoStreamType::PixelFormat::kYv12: |
| 321 return os << "kYv12"; |
| 322 case VideoStreamType::PixelFormat::kYv16: |
| 323 return os << "kYv16"; |
| 324 case VideoStreamType::PixelFormat::kYv12A: |
| 325 return os << "kYv12A"; |
| 326 case VideoStreamType::PixelFormat::kYv24: |
| 327 return os << "kYv24"; |
| 328 case VideoStreamType::PixelFormat::kNv12: |
| 329 return os << "kNv12"; |
| 330 case VideoStreamType::PixelFormat::kNv21: |
| 331 return os << "kNv21"; |
| 332 case VideoStreamType::PixelFormat::kUyvy: |
| 333 return os << "kUyvy"; |
| 334 case VideoStreamType::PixelFormat::kYuy2: |
| 335 return os << "kYuy2"; |
| 336 case VideoStreamType::PixelFormat::kArgb: |
| 337 return os << "kArgb"; |
| 338 case VideoStreamType::PixelFormat::kXrgb: |
| 339 return os << "kXrgb"; |
| 340 case VideoStreamType::PixelFormat::kRgb24: |
| 341 return os << "kRgb24"; |
| 342 case VideoStreamType::PixelFormat::kRgb32: |
| 343 return os << "kRgb24"; |
| 344 case VideoStreamType::PixelFormat::kMjpeg: |
| 345 return os << "kRgb24"; |
| 346 case VideoStreamType::PixelFormat::kMt21: |
| 347 return os << "kRgb24"; |
| 348 } |
| 349 } |
| 350 |
| 351 std::ostream& operator<<(std::ostream& os, VideoStreamType::ColorSpace value) { |
| 352 switch (value) { |
| 353 case VideoStreamType::ColorSpace::kUnknown: |
| 354 return os << "kUnknown"; |
| 355 case VideoStreamType::ColorSpace::kNotApplicable: |
| 356 return os << "kNotApplicable"; |
| 357 case VideoStreamType::ColorSpace::kJpeg: |
| 358 return os << "kJpeg"; |
| 359 case VideoStreamType::ColorSpace::kHdRec709: |
| 360 return os << "kHdRec709"; |
| 361 case VideoStreamType::ColorSpace::kSdRec601: |
| 362 return os << "kSdRec601"; |
| 363 } |
| 364 } |
| 365 |
| 366 std::ostream& operator<<(std::ostream& os, const BytesPtr& value) { |
| 367 if (value == nullptr) { |
| 368 return os << "<nullptr>"; |
| 369 } else { |
| 370 return os << value->size() << " bytes"; |
| 371 } |
| 372 } |
| 373 |
| 374 std::ostream& operator<<(std::ostream& os, Range<bool> value) { |
| 375 if (value.min) { |
| 376 return os << "true"; |
| 377 } else if (value.max) { |
| 378 return os << "false..true"; |
| 379 } else { |
| 380 return os << "false"; |
| 381 } |
| 382 } |
| 383 |
| 384 } // namespace media |
| 385 } // namespace mojo |
OLD | NEW |