Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: media/base/android/video_decoder_job.h

Issue 254473010: Refactor MSE implementation on Android to simplify the logic and improve the performance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_ 5 #ifndef MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_
6 #define MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_ 6 #define MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "media/base/android/media_decoder_job.h" 10 #include "media/base/android/media_decoder_job.h"
11 11
12 namespace media { 12 namespace media {
13 13
14 class VideoCodecBridge; 14 class VideoCodecBridge;
15 15
16 // Class for managing video decoding jobs. 16 // Class for managing video decoding jobs.
17 class VideoDecoderJob : public MediaDecoderJob { 17 class VideoDecoderJob : public MediaDecoderJob {
18 public: 18 public:
19 virtual ~VideoDecoderJob();
20
21 // Create a new VideoDecoderJob instance. 19 // Create a new VideoDecoderJob instance.
22 // |video_codec| - The video format the object needs to decode.
23 // |is_secure| - Whether secure decoding is required.
24 // |size| - The natural size of the output frames.
25 // |surface| - The surface to render the frames to.
26 // |media_crypto| - Handle to a Java object responsible for decrypting the
27 // video data.
28 // |request_data_cb| - Callback used to request more data for the decoder. 20 // |request_data_cb| - Callback used to request more data for the decoder.
29 // |request_resources_cb| - Callback used to request resources. 21 // |request_resources_cb| - Callback used to request resources.
30 // |release_resources_cb| - Callback used to release resources. 22 // |release_resources_cb| - Callback used to release resources.
31 static VideoDecoderJob* Create(const VideoCodec video_codec, 23 // |on_demuxer_config_changed_cb| - Callback used to inform the caller that
32 bool is_secure, 24 // demuxer config has changed.
33 const gfx::Size& size, 25 VideoDecoderJob(
34 jobject surface, 26 const base::Closure& request_data_cb,
35 jobject media_crypto, 27 const base::Closure& request_resources_cb,
36 const base::Closure& request_data_cb, 28 const base::Closure& release_resources_cb,
37 const base::Closure& request_resources_cb, 29 const base::Closure& on_demuxer_config_changed_cb);
38 const base::Closure& release_resources_cb); 30 ~VideoDecoderJob();
31
32 // Passing an java surface object to the codec.
33 bool SetVideoSurface(gfx::ScopedJavaSurface surface);
34
35 // MediaDecoderJob implementation.
36 virtual bool HasStream() const OVERRIDE;
37 virtual void Flush() OVERRIDE;
38 virtual void ReleaseDecoderResources() OVERRIDE;
39
40 bool next_video_data_is_iframe() {
41 return next_video_data_is_iframe_;
42 }
43
44 int width() const { return width_; }
45 int height() const { return height_; }
39 46
40 private: 47 private:
41 VideoDecoderJob(scoped_ptr<VideoCodecBridge> video_codec_bridge,
42 const base::Closure& request_data_cb,
43 const base::Closure& request_resources_cb,
44 const base::Closure& release_resources_cb);
45
46 // MediaDecoderJob implementation. 48 // MediaDecoderJob implementation.
47 virtual void ReleaseOutputBuffer( 49 virtual void ReleaseOutputBuffer(
48 int output_buffer_index, 50 int output_buffer_index,
49 size_t size, 51 size_t size,
50 bool render_output, 52 bool render_output,
51 base::TimeDelta current_presentation_timestamp, 53 base::TimeDelta current_presentation_timestamp,
52 const ReleaseOutputCompletionCallback& callback) OVERRIDE; 54 const ReleaseOutputCompletionCallback& callback) OVERRIDE;
55 virtual bool ComputeTimeToRender() const OVERRIDE;
56 virtual void UpdateDemuxerConfigs(const DemuxerConfigs& configs) OVERRIDE;
57 virtual bool IsDemuxerConfigChanged(
58 const DemuxerConfigs& configs) const OVERRIDE;
59 virtual bool CreateMediaCodecBridgeInternal() OVERRIDE;
60 virtual void CurrentDataConsumed(bool is_config_change) OVERRIDE;
61 virtual void OnMediaCodecBridgeReleased() OVERRIDE;
53 62
54 virtual bool ComputeTimeToRender() const OVERRIDE; 63 // Returns true if a protected surface is required for video playback.
64 bool IsProtectedSurfaceRequired();
55 65
56 scoped_ptr<VideoCodecBridge> video_codec_bridge_; 66 // Video configs from the demuxer.
67 VideoCodec video_codec_;
68 int width_;
69 int height_;
57 70
71 // The surface object currently owned by the player.
72 gfx::ScopedJavaSurface surface_;
73
74 // Callbacks to inform the caller about decoder resources change.
75 base::Closure request_resources_cb_;
58 base::Closure release_resources_cb_; 76 base::Closure release_resources_cb_;
77
78 // Track whether the next access unit is an I-frame. The first access
79 // unit after Flush() and CurrentDataConsumed(true) is guaranteed to be an
80 // I-frame.
81 bool next_video_data_is_iframe_;
82
83 DISALLOW_COPY_AND_ASSIGN(VideoDecoderJob);
59 }; 84 };
60 85
61 } // namespace media 86 } // namespace media
62 87
63 #endif // MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_ 88 #endif // MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698