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