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 #ifndef SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DECODER_BASE_H_ | 5 #ifndef SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DECODER_BASE_H_ |
6 #define SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DECODER_BASE_H_ | 6 #define SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DECODER_BASE_H_ |
7 | 7 |
8 #include "services/media/framework/parts/decoder.h" | 8 #include "services/media/framework/parts/decoder.h" |
9 #include "services/media/framework_ffmpeg/av_codec_context.h" | 9 #include "services/media/framework_ffmpeg/av_codec_context.h" |
10 #include "services/media/framework_ffmpeg/av_frame.h" | 10 #include "services/media/framework_ffmpeg/av_frame.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 FfmpegDecoderBase(AvCodecContextPtr av_codec_context); | 22 FfmpegDecoderBase(AvCodecContextPtr av_codec_context); |
23 | 23 |
24 ~FfmpegDecoderBase() override; | 24 ~FfmpegDecoderBase() override; |
25 | 25 |
26 // Decoder implementation. | 26 // Decoder implementation. |
27 std::unique_ptr<StreamType> output_stream_type() override; | 27 std::unique_ptr<StreamType> output_stream_type() override; |
28 | 28 |
29 // Transform implementation. | 29 // Transform implementation. |
30 void Flush() override; | 30 void Flush() override; |
31 | 31 |
32 bool TransformPacket( | 32 bool TransformPacket(const PacketPtr& input, |
33 const PacketPtr& input, | 33 bool new_input, |
34 bool new_input, | 34 PayloadAllocator* allocator, |
35 PayloadAllocator* allocator, | 35 PacketPtr* output) override; |
36 PacketPtr* output) override; | |
37 | 36 |
38 protected: | 37 protected: |
39 // Decodes from av_packet into av_frame_ptr. The result indicates how many | 38 // Decodes from av_packet into av_frame_ptr. The result indicates how many |
40 // bytes were consumed from av_packet_. *frame_decoded_out indicates whether | 39 // bytes were consumed from av_packet_. *frame_decoded_out indicates whether |
41 // av_frame_ptr contains a complete frame. | 40 // av_frame_ptr contains a complete frame. |
42 virtual int Decode( | 41 virtual int Decode(const AVPacket& av_packet, |
43 const AVPacket& av_packet, | 42 const ffmpeg::AvFramePtr& av_frame_ptr, |
44 const ffmpeg::AvFramePtr& av_frame_ptr, | 43 PayloadAllocator* allocator, |
45 PayloadAllocator* allocator, | 44 bool* frame_decoded_out) = 0; |
46 bool* frame_decoded_out) = 0; | |
47 | 45 |
48 // Creates a Packet from av_frame. | 46 // Creates a Packet from av_frame. |
49 virtual PacketPtr CreateOutputPacket( | 47 virtual PacketPtr CreateOutputPacket(const AVFrame& av_frame, |
50 const AVFrame& av_frame, | 48 PayloadAllocator* allocator) = 0; |
51 PayloadAllocator* allocator) = 0; | |
52 | 49 |
53 // Creates an end-of-stream packet with no payload. | 50 // Creates an end-of-stream packet with no payload. |
54 virtual PacketPtr CreateOutputEndOfStreamPacket() = 0; | 51 virtual PacketPtr CreateOutputEndOfStreamPacket() = 0; |
55 | 52 |
56 // The ffmpeg codec context. | 53 // The ffmpeg codec context. |
57 const AvCodecContextPtr& context() { | 54 const AvCodecContextPtr& context() { return av_codec_context_; } |
58 return av_codec_context_; | |
59 } | |
60 | 55 |
61 private: | 56 private: |
62 // Prepares to process a new input packet. | 57 // Prepares to process a new input packet. |
63 void PrepareInputPacket(const PacketPtr& input); | 58 void PrepareInputPacket(const PacketPtr& input); |
64 | 59 |
65 // Finishes up after processing of an input packet has completed, possibly | 60 // Finishes up after processing of an input packet has completed, possibly |
66 // producing a zero-size end-of-stream packet. Returns true to indicate that | 61 // producing a zero-size end-of-stream packet. Returns true to indicate that |
67 // a new input packet is required. | 62 // a new input packet is required. |
68 bool UnprepareInputPacket(const PacketPtr& input, PacketPtr* output); | 63 bool UnprepareInputPacket(const PacketPtr& input, PacketPtr* output); |
69 | 64 |
70 AvCodecContextPtr av_codec_context_; | 65 AvCodecContextPtr av_codec_context_; |
71 AVPacket av_packet_; | 66 AVPacket av_packet_; |
72 ffmpeg::AvFramePtr av_frame_ptr_; | 67 ffmpeg::AvFramePtr av_frame_ptr_; |
73 }; | 68 }; |
74 | 69 |
75 } // namespace media | 70 } // namespace media |
76 } // namespace mojo | 71 } // namespace mojo |
77 | 72 |
78 #endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DECODER_BASE_H_ | 73 #endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_FFMPEG_DECODER_BASE_H_ |
OLD | NEW |