Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PIPELINE_H_ | 5 #ifndef MEDIA_BASE_PIPELINE_H_ |
| 6 #define MEDIA_BASE_PIPELINE_H_ | 6 #define MEDIA_BASE_PIPELINE_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "media/base/buffering_state.h" | 10 #include "media/base/buffering_state.h" |
| 11 #include "media/base/cdm_context.h" | 11 #include "media/base/cdm_context.h" |
| 12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 13 #include "media/base/pipeline_metadata.h" | |
| 13 #include "media/base/pipeline_status.h" | 14 #include "media/base/pipeline_status.h" |
| 14 #include "media/base/ranges.h" | 15 #include "media/base/ranges.h" |
| 15 #include "media/base/text_track.h" | 16 #include "media/base/text_track.h" |
| 16 #include "media/base/video_rotation.h" | 17 #include "media/base/video_rotation.h" |
| 17 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 | 21 |
| 21 class Demuxer; | 22 class Demuxer; |
| 23 class PipelineClient; | |
| 22 class Renderer; | 24 class Renderer; |
| 23 class VideoFrame; | 25 class VideoFrame; |
| 24 | 26 |
| 25 // Metadata describing a pipeline once it has been initialized. | |
| 26 struct PipelineMetadata { | |
| 27 PipelineMetadata() | |
| 28 : has_audio(false), has_video(false), video_rotation(VIDEO_ROTATION_0) {} | |
| 29 | |
| 30 bool has_audio; | |
| 31 bool has_video; | |
| 32 gfx::Size natural_size; | |
| 33 VideoRotation video_rotation; | |
| 34 base::Time timeline_offset; | |
| 35 }; | |
| 36 | |
| 37 typedef base::Callback<void(PipelineMetadata)> PipelineMetadataCB; | |
| 38 | |
| 39 class MEDIA_EXPORT Pipeline { | 27 class MEDIA_EXPORT Pipeline { |
| 40 public: | 28 public: |
| 41 // Used to paint VideoFrame. | 29 virtual ~Pipeline() {} |
| 42 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; | |
| 43 | 30 |
| 44 // Build a pipeline to using the given |demuxer| and |renderer| to construct | 31 // Build a pipeline to using the given |demuxer| and |renderer| to construct |
| 45 // a filter chain, executing |seek_cb| when the initial seek has completed. | 32 // a filter chain, executing |seek_cb| when the initial seek has completed. |
| 46 // | 33 // |
| 47 // The following permanent callbacks will be executed as follows up until | 34 // The following permanent callbacks will be executed on PipelineClient up |
| 48 // Stop() has completed: | 35 // until Stop() has completed: |
| 49 // |ended_cb| will be executed whenever the media reaches the end. | 36 // OnError |
| 50 // |error_cb| will be executed whenever an error occurs but hasn't been | 37 // OnEnded |
| 51 // reported already through another callback. | 38 // OnMetadata |
| 52 // |metadata_cb| will be executed when the content duration, container video | 39 // OnBufferingStateChange |
| 53 // size, start time, and whether the content has audio and/or | 40 // OnDurationChange |
| 54 // video in supported formats are known. | 41 // OnAddTextTrack |
| 55 // |buffering_state_cb| will be executed whenever there are changes in the | 42 // OnWaitingForDecryptionKey |
| 56 // overall buffering state of the pipeline. | 43 // |
| 57 // |duration_change_cb| optional callback that will be executed whenever the | |
| 58 // presentation duration changes. | |
| 59 // |add_text_track_cb| will be executed whenever a text track is added. | |
| 60 // |waiting_for_decryption_key_cb| will be executed whenever the key needed | |
| 61 // to decrypt the stream is not available. | |
| 62 // It is an error to call this method after the pipeline has already started. | 44 // It is an error to call this method after the pipeline has already started. |
| 63 virtual void Start(Demuxer* demuxer, | 45 virtual void Start(Demuxer* demuxer, |
| 64 scoped_ptr<Renderer> renderer, | 46 scoped_ptr<Renderer> renderer, |
| 65 const base::Closure& ended_cb, | 47 const PipelineStatusCB& seek_cb) = 0; |
|
sandersd (OOO until July 31)
2016/04/21 00:36:30
Are we going to rename this init_cb while we are a
xhwang
2016/04/21 05:50:35
Or |start_cb|?
alokp
2016/04/21 21:56:38
This particular callback is shared between Start,
xhwang
2016/04/21 22:26:04
Right. We should separate the initial seek_cb (for
alokp
2016/04/22 05:08:59
I will need to look into this closely. I think thi
xhwang
2016/04/22 16:05:05
sgtm. A TODO would be nice here.
| |
| 66 const PipelineStatusCB& error_cb, | |
| 67 const PipelineStatusCB& seek_cb, | |
| 68 const PipelineMetadataCB& metadata_cb, | |
| 69 const BufferingStateCB& buffering_state_cb, | |
| 70 const base::Closure& duration_change_cb, | |
| 71 const AddTextTrackCB& add_text_track_cb, | |
| 72 const base::Closure& waiting_for_decryption_key_cb) = 0; | |
| 73 | 48 |
| 74 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline | 49 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline |
| 75 // teardown has completed. | 50 // teardown has completed. |
| 76 // | 51 // |
| 77 // Stop() must complete before destroying the pipeline. It it permissible to | 52 // Stop() must complete before destroying the pipeline. It it permissible to |
| 78 // call Stop() at any point during the lifetime of the pipeline. | 53 // call Stop() at any point during the lifetime of the pipeline. |
| 79 // | 54 // |
| 80 // It is safe to delete the pipeline during the execution of |stop_cb|. | 55 // It is safe to delete the pipeline during the execution of |stop_cb|. |
| 81 virtual void Stop(const base::Closure& stop_cb) = 0; | 56 virtual void Stop(const base::Closure& stop_cb) = 0; |
| 82 | 57 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 | 123 |
| 149 // Return true if loading progress has been made since the last time this | 124 // Return true if loading progress has been made since the last time this |
| 150 // method was called. | 125 // method was called. |
| 151 virtual bool DidLoadingProgress() = 0; | 126 virtual bool DidLoadingProgress() = 0; |
| 152 | 127 |
| 153 // Gets the current pipeline statistics. | 128 // Gets the current pipeline statistics. |
| 154 virtual PipelineStatistics GetStatistics() const = 0; | 129 virtual PipelineStatistics GetStatistics() const = 0; |
| 155 | 130 |
| 156 virtual void SetCdm(CdmContext* cdm_context, | 131 virtual void SetCdm(CdmContext* cdm_context, |
| 157 const CdmAttachedCB& cdm_attached_cb) = 0; | 132 const CdmAttachedCB& cdm_attached_cb) = 0; |
| 133 | |
| 134 protected: | |
| 135 Pipeline(PipelineClient* client) : client_(client) {} | |
|
xhwang
2016/04/21 05:50:35
What's the value of putting this in "protected"? P
alokp
2016/04/21 21:56:38
Done.
| |
| 136 | |
| 137 PipelineClient* client() const { return client_; } | |
| 138 | |
| 139 private: | |
| 140 PipelineClient* client_; | |
|
xhwang
2016/04/21 05:50:35
This would work. But I am not a huge fan of storin
alokp
2016/04/21 21:56:38
Yeah this will work since client is only being use
xhwang
2016/04/21 22:26:04
The Start() is really a combination of both Initia
xhwang
2016/04/21 22:32:05
To be clear. I am not proposing this change. Just
alokp
2016/04/22 05:08:59
This is a minor thing. I have kept it in Start for
| |
| 158 }; | 141 }; |
| 159 | 142 |
| 160 } // namespace media | 143 } // namespace media |
| 161 | 144 |
| 162 #endif // MEDIA_BASE_PIPELINE_H_ | 145 #endif // MEDIA_BASE_PIPELINE_H_ |
| OLD | NEW |