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

Side by Side Diff: media/base/pipeline.h

Issue 1904793002: Move Pipeline permanent callbacks into Pipeline::Client interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: restored lock during stop Created 4 years, 7 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
OLDNEW
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 <memory> 8 #include <memory>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "media/base/buffering_state.h" 12 #include "media/base/buffering_state.h"
13 #include "media/base/cdm_context.h" 13 #include "media/base/cdm_context.h"
14 #include "media/base/media_export.h" 14 #include "media/base/media_export.h"
15 #include "media/base/pipeline_metadata.h"
15 #include "media/base/pipeline_status.h" 16 #include "media/base/pipeline_status.h"
16 #include "media/base/ranges.h" 17 #include "media/base/ranges.h"
17 #include "media/base/text_track.h" 18 #include "media/base/text_track.h"
18 #include "media/base/video_rotation.h" 19 #include "media/base/video_rotation.h"
19 #include "ui/gfx/geometry/size.h" 20 #include "ui/gfx/geometry/size.h"
20 21
21 namespace media { 22 namespace media {
22 23
23 class Demuxer; 24 class Demuxer;
24 class Renderer; 25 class Renderer;
25 class VideoFrame; 26 class VideoFrame;
26 27
27 // Metadata describing a pipeline once it has been initialized.
28 struct PipelineMetadata {
29 PipelineMetadata()
30 : has_audio(false), has_video(false), video_rotation(VIDEO_ROTATION_0) {}
31
32 bool has_audio;
33 bool has_video;
34 gfx::Size natural_size;
35 VideoRotation video_rotation;
36 base::Time timeline_offset;
37 };
38
39 typedef base::Callback<void(PipelineMetadata)> PipelineMetadataCB;
40
41 class MEDIA_EXPORT Pipeline { 28 class MEDIA_EXPORT Pipeline {
42 public: 29 public:
43 // Used to paint VideoFrame. 30 class Client {
44 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; 31 public:
32 virtual ~Client() {}
sandersd (OOO until July 31) 2016/05/02 18:37:47 I still don't think we want to expose a destructor
alokp 2016/05/02 22:25:17 Done.
33
34 // Executed whenever an error occurs but hasn't been reported already
35 // through another callback.
36 virtual void OnError(PipelineStatus status) {}
37
38 // Executed whenever the media reaches the end.
39 virtual void OnEnded() {}
40
41 // Executed when the content duration, container video size, start time,
42 // and whether the content has audio and/or video in supported formats are
43 // known.
44 virtual void OnMetadata(PipelineMetadata metadata) {}
45
46 // Executed whenever there are changes in the buffering state of the
47 // pipeline.
48 virtual void OnBufferingStateChange(BufferingState state) {}
49
50 // Executed whenever the presentation duration changes.
51 virtual void OnDurationChange() {}
52
53 // Executed whenever a text track is added.
54 virtual void OnAddTextTrack(const TextTrackConfig& config,
55 const AddTextTrackDoneCB& done_cb) {}
56
57 // Executed whenever the key needed to decrypt the stream is not available.
58 virtual void OnWaitingForDecryptionKey() {}
xhwang 2016/05/02 20:58:35 How much does the default implementations save us
alokp 2016/05/02 22:25:17 Client is now abstract.
59 };
60
61 virtual ~Pipeline() {}
45 62
46 // Build a pipeline to using the given |demuxer| and |renderer| to construct 63 // Build a pipeline to using the given |demuxer| and |renderer| to construct
47 // a filter chain, executing |seek_cb| when the initial seek has completed. 64 // a filter chain, executing |seek_cb| when the initial seek has completed.
48 // 65 //
49 // The following permanent callbacks will be executed as follows up until 66 // The following permanent callbacks will be executed on PipelineClient up
50 // Stop() has completed: 67 // until Stop() has completed:
51 // |ended_cb| will be executed whenever the media reaches the end. 68 // OnError
52 // |error_cb| will be executed whenever an error occurs but hasn't been 69 // OnEnded
53 // reported already through another callback. 70 // OnMetadata
54 // |metadata_cb| will be executed when the content duration, container video 71 // OnBufferingStateChange
55 // size, start time, and whether the content has audio and/or 72 // OnDurationChange
56 // video in supported formats are known. 73 // OnAddTextTrack
57 // |buffering_state_cb| will be executed whenever there are changes in the 74 // OnWaitingForDecryptionKey
58 // overall buffering state of the pipeline. 75 //
59 // |duration_change_cb| optional callback that will be executed whenever the
60 // presentation duration changes.
61 // |add_text_track_cb| will be executed whenever a text track is added.
62 // |waiting_for_decryption_key_cb| will be executed whenever the key needed
63 // to decrypt the stream is not available.
64 // It is an error to call this method after the pipeline has already started. 76 // It is an error to call this method after the pipeline has already started.
77 // TODO(xhwang): Rename |seek_cb| to |start_cb|.
65 virtual void Start(Demuxer* demuxer, 78 virtual void Start(Demuxer* demuxer,
66 std::unique_ptr<Renderer> renderer, 79 std::unique_ptr<Renderer> renderer,
67 const base::Closure& ended_cb, 80 Client* client,
68 const PipelineStatusCB& error_cb, 81 const PipelineStatusCB& seek_cb) = 0;
69 const PipelineStatusCB& seek_cb,
70 const PipelineMetadataCB& metadata_cb,
71 const BufferingStateCB& buffering_state_cb,
72 const base::Closure& duration_change_cb,
73 const AddTextTrackCB& add_text_track_cb,
74 const base::Closure& waiting_for_decryption_key_cb) = 0;
75 82
76 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline 83 // Stops the pipeline. This is a blocking function.
77 // teardown has completed. 84 // The pipeline must be stopped before destroying it.
85 // It it permissible to call Stop() at any point during the lifetime of the
86 // pipeline.
78 // 87 //
79 // Stop() must complete before destroying the pipeline. It it permissible to 88 // Once Stop is called any outstanding completion callbacks
80 // call Stop() at any point during the lifetime of the pipeline. 89 // for Start/Seek/Suspend/Resume or PipelineClient callbacks will *not*
81 // 90 // be called.
82 // It is safe to delete the pipeline during the execution of |stop_cb|. 91 virtual void Stop() = 0;
83 virtual void Stop(const base::Closure& stop_cb) = 0;
84 92
85 // Attempt to seek to the position specified by time. |seek_cb| will be 93 // Attempt to seek to the position specified by time. |seek_cb| will be
86 // executed when the all filters in the pipeline have processed the seek. 94 // executed when the all filters in the pipeline have processed the seek.
87 // 95 //
88 // Clients are expected to call GetMediaTime() to check whether the seek 96 // Clients are expected to call GetMediaTime() to check whether the seek
89 // succeeded. 97 // succeeded.
90 // 98 //
91 // It is an error to call this method if the pipeline has not started or 99 // It is an error to call this method if the pipeline has not started or
92 // has been suspended. 100 // has been suspended.
93 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) = 0; 101 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) = 0;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // Gets the current pipeline statistics. 163 // Gets the current pipeline statistics.
156 virtual PipelineStatistics GetStatistics() const = 0; 164 virtual PipelineStatistics GetStatistics() const = 0;
157 165
158 virtual void SetCdm(CdmContext* cdm_context, 166 virtual void SetCdm(CdmContext* cdm_context,
159 const CdmAttachedCB& cdm_attached_cb) = 0; 167 const CdmAttachedCB& cdm_attached_cb) = 0;
160 }; 168 };
161 169
162 } // namespace media 170 } // namespace media
163 171
164 #endif // MEDIA_BASE_PIPELINE_H_ 172 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698