| 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 // For parameters see media_codec_decoder.h | |
| 23 // update_current_time_cb: callback that reports current playback time. | |
| 24 // Called for released output frame, | |
| 25 // video_size_changed_cb: reports the new video size, | |
| 26 // codec_created_cb: reports that video codec has been created. A controller | |
| 27 // class might use it to release more resources so that this | |
| 28 // decoder can use them. | |
| 29 MediaCodecVideoDecoder( | |
| 30 const scoped_refptr<base::SingleThreadTaskRunner>& media_runner, | |
| 31 const base::Closure& request_data_cb, | |
| 32 const base::Closure& starvation_cb, | |
| 33 const base::Closure& stop_done_cb, | |
| 34 const base::Closure& error_cb, | |
| 35 const SetTimeCallback& update_current_time_cb, | |
| 36 const VideoSizeChangedCallback& video_size_changed_cb, | |
| 37 const base::Closure& codec_created_cb); | |
| 38 ~MediaCodecVideoDecoder() override; | |
| 39 | |
| 40 const char* class_name() const override; | |
| 41 | |
| 42 bool HasStream() const override; | |
| 43 void SetDemuxerConfigs(const DemuxerConfigs& configs) override; | |
| 44 void ReleaseDecoderResources() override; | |
| 45 | |
| 46 // Stores the video surface to use with upcoming Configure() | |
| 47 void SetPendingSurface(gfx::ScopedJavaSurface surface); | |
| 48 | |
| 49 // Returns true if there is a video surface to use. | |
| 50 bool HasPendingSurface() const; | |
| 51 | |
| 52 protected: | |
| 53 bool IsCodecReconfigureNeeded(const DemuxerConfigs& curr, | |
| 54 const DemuxerConfigs& next) const override; | |
| 55 ConfigStatus ConfigureInternal() override; | |
| 56 void SynchronizePTSWithTime(base::TimeDelta current_time) override; | |
| 57 void OnOutputFormatChanged() override; | |
| 58 void Render(int buffer_index, | |
| 59 size_t size, | |
| 60 bool render_output, | |
| 61 base::TimeDelta pts, | |
| 62 bool eos_encountered) override; | |
| 63 | |
| 64 int NumDelayedRenderTasks() const override; | |
| 65 void ReleaseDelayedBuffers() override; | |
| 66 | |
| 67 private: | |
| 68 // A helper method that releases output buffers and does | |
| 69 // post-release checks. Might be called by Render() or posted | |
| 70 // for later execution. | |
| 71 void ReleaseOutputBuffer(int buffer_index, | |
| 72 base::TimeDelta pts, | |
| 73 bool render, | |
| 74 bool eos_encountered); | |
| 75 | |
| 76 // Data. | |
| 77 | |
| 78 // Configuration received from demuxer | |
| 79 DemuxerConfigs configs_; | |
| 80 | |
| 81 // Video surface that we render to. | |
| 82 gfx::ScopedJavaSurface surface_; | |
| 83 | |
| 84 // Reports current playback time to the callee. | |
| 85 SetTimeCallback update_current_time_cb_; | |
| 86 | |
| 87 // Informs the callee that video size is changed. | |
| 88 VideoSizeChangedCallback video_size_changed_cb_; | |
| 89 | |
| 90 // Informs the callee that the MediaCodec is created. | |
| 91 base::Closure codec_created_cb_; | |
| 92 | |
| 93 // Current video size to be sent with |video_size_changed_cb_|. | |
| 94 gfx::Size video_size_; | |
| 95 | |
| 96 // Indices of output buffers that are posted for rendering. | |
| 97 std::set<int> delayed_buffers_; | |
| 98 | |
| 99 // Associate presentation timestamps with time. | |
| 100 base::TimeTicks start_time_ticks_; | |
| 101 base::TimeDelta start_pts_; | |
| 102 | |
| 103 // Mantain the last seen PTS for stand-alone EOS. | |
| 104 base::TimeDelta last_seen_pts_; | |
| 105 | |
| 106 DISALLOW_COPY_AND_ASSIGN(MediaCodecVideoDecoder); | |
| 107 }; | |
| 108 | |
| 109 } // namespace media | |
| 110 | |
| 111 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_VIDEO_DECODER_H_ | |
| OLD | NEW |