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 VideoSizeChangedCallback& video_size_changed_cb, | |
29 const base::Closure& codec_created_cb); | |
30 ~MediaCodecVideoDecoder() override; | |
31 | |
32 const char* class_name() const override { return "VideoDecoder"; } | |
33 | |
34 bool HasStream() const override; | |
35 void SetDemuxerConfigs(const DemuxerConfigs& configs) override; | |
36 void ReleaseDecoderResources() override; | |
37 | |
38 // Stores the video surface to use with upcoming Configure() | |
39 void SetPendingSurface(gfx::ScopedJavaSurface surface); | |
40 | |
41 // Returns true if there is a video surface to use. | |
42 bool HasPendingSurface() const; | |
43 | |
44 protected: | |
45 bool IsCodecReconfigureNeeded(const DemuxerConfigs& curr, | |
46 const DemuxerConfigs& next) const override; | |
47 ConfigStatus ConfigureInternal() override; | |
48 void SynchronizePTSWithTime(base::TimeDelta current_time) override; | |
49 void OnOutputFormatChanged() override; | |
50 void Render(int buffer_index, size_t size, bool render_output, | |
51 base::TimeDelta pts, bool eos_encountered) override; | |
52 | |
53 int NumDelayedRenderTasks() const override; | |
54 void ReleaseDelayedBuffers() override; | |
55 | |
56 private: | |
57 // A helper method that releases output buffers and does | |
58 // post-release checks. Might be called by Render() or posted | |
59 // for later execution. | |
60 void ReleaseOutputBuffer(int buffer_index, bool render, | |
61 bool eos_encountered); | |
62 | |
63 // Data. | |
64 | |
65 // Configuration received from demuxer | |
66 DemuxerConfigs configs_; | |
67 | |
68 // Video surface that we render to. | |
69 gfx::ScopedJavaSurface surface_; | |
70 | |
71 // Informs the callee that video size is changed. | |
72 VideoSizeChangedCallback video_size_changed_cb_; | |
73 | |
74 // Informs the callee that the MediaCodec is created. | |
75 base::Closure codec_created_cb_; | |
76 | |
77 // Current video size to be sent with |video_size_changed_cb_|. | |
78 gfx::Size video_size_; | |
79 | |
80 // Indexes ouf output buffers that are posted for rendering. | |
watk
2015/06/05 01:00:33
s/Indexes ouf/Indices of
Tima Vaisburd
2015/06/05 04:17:47
Done.
| |
81 std::set<int> delayed_buffers_; | |
82 | |
83 // Associate presentation timestamps with time | |
84 base::TimeTicks start_time_ticks_; | |
85 base::TimeDelta start_pts_; | |
86 | |
87 // Mantain last seen PTS for stand-alone EOS | |
88 base::TimeDelta last_seen_pts_; | |
89 | |
90 DISALLOW_COPY_AND_ASSIGN(MediaCodecVideoDecoder); | |
91 }; | |
92 | |
93 } // namespace media | |
94 | |
95 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_VIDEO_DECODER_H_ | |
OLD | NEW |