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