| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "services/media/framework_ffmpeg/ffmpeg_type_converters.h" | 6 #include "services/media/framework_ffmpeg/av_codec_context.h" |
| 7 #include "services/media/framework_ffmpeg/ffmpeg_init.h" |
| 7 extern "C" { | 8 extern "C" { |
| 8 #include "third_party/ffmpeg/libavformat/avformat.h" | 9 #include "third_party/ffmpeg/libavformat/avformat.h" |
| 9 } | 10 } |
| 10 | 11 |
| 11 // Ffmeg defines this...undefine. | 12 // Ffmeg defines this...undefine. |
| 12 #undef PixelFormat | 13 #undef PixelFormat |
| 13 | 14 |
| 14 namespace mojo { | 15 namespace mojo { |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 328 |
| 328 if (stream_type.encoding_details()) { | 329 if (stream_type.encoding_details()) { |
| 329 ExtraDataFromBytes(*stream_type.encoding_details(), context); | 330 ExtraDataFromBytes(*stream_type.encoding_details(), context); |
| 330 } | 331 } |
| 331 | 332 |
| 332 return context; | 333 return context; |
| 333 } | 334 } |
| 334 | 335 |
| 335 } // namespace | 336 } // namespace |
| 336 | 337 |
| 337 std::unique_ptr<StreamType> StreamTypeFromAVCodecContext( | 338 // static |
| 339 std::unique_ptr<StreamType> AvCodecContext::GetStreamType( |
| 338 const AVCodecContext& from) { | 340 const AVCodecContext& from) { |
| 339 switch (from.codec_type) { | 341 switch (from.codec_type) { |
| 340 case AVMEDIA_TYPE_AUDIO: | 342 case AVMEDIA_TYPE_AUDIO: |
| 341 switch (from.codec_id) { | 343 switch (from.codec_id) { |
| 342 case CODEC_ID_PCM_S16BE: | 344 case CODEC_ID_PCM_S16BE: |
| 343 case CODEC_ID_PCM_S16LE: | 345 case CODEC_ID_PCM_S16LE: |
| 344 case CODEC_ID_PCM_S24BE: | 346 case CODEC_ID_PCM_S24BE: |
| 345 case CODEC_ID_PCM_S24LE: | 347 case CODEC_ID_PCM_S24LE: |
| 346 case CODEC_ID_PCM_U8: | 348 case CODEC_ID_PCM_U8: |
| 347 return StreamTypeFromLpcmCodecContext(from); | 349 return StreamTypeFromLpcmCodecContext(from); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 360 return StreamTypeFromDataCodecContext(from); | 362 return StreamTypeFromDataCodecContext(from); |
| 361 case AVMEDIA_TYPE_SUBTITLE: | 363 case AVMEDIA_TYPE_SUBTITLE: |
| 362 return StreamTypeFromSubtitleCodecContext(from); | 364 return StreamTypeFromSubtitleCodecContext(from); |
| 363 case AVMEDIA_TYPE_ATTACHMENT: | 365 case AVMEDIA_TYPE_ATTACHMENT: |
| 364 case AVMEDIA_TYPE_NB: | 366 case AVMEDIA_TYPE_NB: |
| 365 default: | 367 default: |
| 366 return StreamType::Create(StreamType::Scheme::kUnknown); | 368 return StreamType::Create(StreamType::Scheme::kUnknown); |
| 367 } | 369 } |
| 368 } | 370 } |
| 369 | 371 |
| 370 AvCodecContextPtr AVCodecContextFromStreamType(const StreamType& stream_type) { | 372 // static |
| 373 AvCodecContextPtr AvCodecContext::Create(const StreamType& stream_type) { |
| 374 InitFfmpeg(); |
| 375 |
| 371 switch (stream_type.scheme()) { | 376 switch (stream_type.scheme()) { |
| 372 case StreamType::Scheme::kLpcm: | 377 case StreamType::Scheme::kLpcm: |
| 373 return CodecContextFromLpcmDetails(*stream_type.lpcm()); | 378 return CodecContextFromLpcmDetails(*stream_type.lpcm()); |
| 374 case StreamType::Scheme::kCompressedAudio: | 379 case StreamType::Scheme::kCompressedAudio: |
| 375 return AVCodecContextFromCompressedAudioStreamType( | 380 return AVCodecContextFromCompressedAudioStreamType( |
| 376 *stream_type.compressed_audio()); | 381 *stream_type.compressed_audio()); |
| 377 case StreamType::Scheme::kVideo: | 382 case StreamType::Scheme::kVideo: |
| 378 return AVCodecContextFromVideoStreamType(*stream_type.video()); | 383 return AVCodecContextFromVideoStreamType(*stream_type.video()); |
| 379 default: | 384 default: |
| 380 return nullptr; | 385 return nullptr; |
| 381 } | 386 } |
| 382 } | 387 } |
| 383 | 388 |
| 384 } // namespace media | 389 } // namespace media |
| 385 } // namespace mojo | 390 } // namespace mojo |
| OLD | NEW |