| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 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 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_VIDEO_DECODER_H_ |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_VIDEO_DECODER_H_ |
| 7 |
| 8 #include <set> |
| 9 #include "media/base/android/media_codec_decoder.h" |
| 10 #include "ui/gfx/geometry/size.h" |
| 11 #include "ui/gl/android/scoped_java_surface.h" |
| 12 |
| 13 namespace media { |
| 14 |
| 15 // Video decoder for MediaCodecPlayer |
| 16 class MediaCodecVideoDecoder : public MediaCodecDecoder { |
| 17 public: |
| 18 // Typedefs for the notification callbacks |
| 19 typedef base::Callback<void(const gfx::Size& video_size)> |
| 20 VideoSizeChangedCallback; |
| 21 |
| 22 MediaCodecVideoDecoder( |
| 23 const scoped_refptr<base::SingleThreadTaskRunner>& media_runner, |
| 24 const base::Closure& request_data_cb, |
| 25 const base::Closure& starvation_cb, |
| 26 const base::Closure& stop_done_cb, |
| 27 const base::Closure& error_cb, |
| 28 const SetTimeCallback& update_current_time_cb, |
| 29 const VideoSizeChangedCallback& video_size_changed_cb, |
| 30 const base::Closure& codec_created_cb); |
| 31 ~MediaCodecVideoDecoder() override; |
| 32 |
| 33 const char* class_name() const override { return "VideoDecoder"; } |
| 34 |
| 35 bool HasStream() const override; |
| 36 void SetDemuxerConfigs(const DemuxerConfigs& configs) override; |
| 37 void ReleaseDecoderResources() override; |
| 38 |
| 39 // Stores the video surface to use with upcoming Configure() |
| 40 void SetPendingSurface(gfx::ScopedJavaSurface surface); |
| 41 |
| 42 // Returns true if there is a video surface to use. |
| 43 bool HasPendingSurface() const; |
| 44 |
| 45 protected: |
| 46 bool IsCodecReconfigureNeeded(const DemuxerConfigs& curr, |
| 47 const DemuxerConfigs& next) const override; |
| 48 ConfigStatus ConfigureInternal() override; |
| 49 void SynchronizePTSWithTime(base::TimeDelta current_time) override; |
| 50 void OnOutputFormatChanged() override; |
| 51 void Render(int buffer_index, |
| 52 size_t size, |
| 53 bool render_output, |
| 54 base::TimeDelta pts, |
| 55 bool eos_encountered) override; |
| 56 |
| 57 int NumDelayedRenderTasks() const override; |
| 58 void ReleaseDelayedBuffers() override; |
| 59 |
| 60 private: |
| 61 // A helper method that releases output buffers and does |
| 62 // post-release checks. Might be called by Render() or posted |
| 63 // for later execution. |
| 64 void ReleaseOutputBuffer(int buffer_index, |
| 65 base::TimeDelta pts, |
| 66 bool render, |
| 67 bool eos_encountered); |
| 68 |
| 69 // Data. |
| 70 |
| 71 // Configuration received from demuxer |
| 72 DemuxerConfigs configs_; |
| 73 |
| 74 // Video surface that we render to. |
| 75 gfx::ScopedJavaSurface surface_; |
| 76 |
| 77 // Reports current playback time to the callee. |
| 78 SetTimeCallback update_current_time_cb_; |
| 79 |
| 80 // Informs the callee that video size is changed. |
| 81 VideoSizeChangedCallback video_size_changed_cb_; |
| 82 |
| 83 // Informs the callee that the MediaCodec is created. |
| 84 base::Closure codec_created_cb_; |
| 85 |
| 86 // Current video size to be sent with |video_size_changed_cb_|. |
| 87 gfx::Size video_size_; |
| 88 |
| 89 // Indices of output buffers that are posted for rendering. |
| 90 std::set<int> delayed_buffers_; |
| 91 |
| 92 // Associate presentation timestamps with time. |
| 93 base::TimeTicks start_time_ticks_; |
| 94 base::TimeDelta start_pts_; |
| 95 |
| 96 // Mantain the last seen PTS for stand-alone EOS. |
| 97 base::TimeDelta last_seen_pts_; |
| 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(MediaCodecVideoDecoder); |
| 100 }; |
| 101 |
| 102 } // namespace media |
| 103 |
| 104 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_VIDEO_DECODER_H_ |
| OLD | NEW |