ac3dc27b108e997d0c6f909c53554562201c0eb5
[platform/framework/web/crosswalk.git] / src / media / base / android / video_decoder_job.h
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_
6 #define MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_
7
8 #include <jni.h>
9
10 #include "media/base/android/media_decoder_job.h"
11
12 namespace media {
13
14 class VideoCodecBridge;
15
16 // Class for managing video decoding jobs.
17 class VideoDecoderJob : public MediaDecoderJob {
18  public:
19   // Create a new VideoDecoderJob instance.
20   // |request_data_cb| - Callback used to request more data for the decoder.
21   // |request_resources_cb| - Callback used to request resources.
22   // |on_demuxer_config_changed_cb| - Callback used to inform the caller that
23   // demuxer config has changed.
24   VideoDecoderJob(
25       const base::Closure& request_data_cb,
26       const base::Closure& request_resources_cb,
27       const base::Closure& on_demuxer_config_changed_cb);
28   virtual ~VideoDecoderJob();
29
30   // Passes a java surface object to the codec. Returns true if the surface
31   // can be used by the decoder, or false otherwise.
32   bool SetVideoSurface(gfx::ScopedJavaSurface surface);
33
34   // MediaDecoderJob implementation.
35   virtual bool HasStream() const OVERRIDE;
36   virtual void Flush() OVERRIDE;
37   virtual void ReleaseDecoderResources() OVERRIDE;
38
39   bool next_video_data_is_iframe() {
40     return next_video_data_is_iframe_;
41   }
42
43   int width() const { return width_; }
44   int height() const { return height_; }
45
46  private:
47   // MediaDecoderJob implementation.
48   virtual void ReleaseOutputBuffer(
49       int output_buffer_index,
50       size_t size,
51       bool render_output,
52       base::TimeDelta current_presentation_timestamp,
53       const ReleaseOutputCompletionCallback& callback) OVERRIDE;
54   virtual bool ComputeTimeToRender() const OVERRIDE;
55   virtual void UpdateDemuxerConfigs(const DemuxerConfigs& configs) OVERRIDE;
56   virtual bool IsCodecReconfigureNeeded(
57       const DemuxerConfigs& configs) const OVERRIDE;
58   virtual bool AreDemuxerConfigsChanged(
59       const DemuxerConfigs& configs) const OVERRIDE;
60   virtual bool CreateMediaCodecBridgeInternal() OVERRIDE;
61   virtual void CurrentDataConsumed(bool is_config_change) OVERRIDE;
62
63   // Returns true if a protected surface is required for video playback.
64   bool IsProtectedSurfaceRequired();
65
66   // Video configs from the demuxer.
67   VideoCodec video_codec_;
68   int width_;
69   int height_;
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_;
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);
84 };
85
86 }  // namespace media
87
88 #endif  // MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_