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

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: cleanup Created 4 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
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 "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;
22 class Renderer; 23 class Renderer;
23 class VideoFrame; 24 class VideoFrame;
24 25
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 { 26 class MEDIA_EXPORT Pipeline {
40 public: 27 public:
41 // Used to paint VideoFrame. 28 class Client {
42 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; 29 public:
30 virtual ~Client() {}
31
32 // Executed whenever an error occurs but hasn't been reported already
33 // through another callback.
34 virtual void OnError(PipelineStatus status) {}
35
36 // Executed whenever the media reaches the end.
37 virtual void OnEnded() {}
38
39 // Executed when the content duration, container video size, start time,
40 // and whether the content has audio and/or video in supported formats are
41 // known.
42 virtual void OnMetadata(PipelineMetadata metadata) {}
43
44 // Executed whenever there are changes in the buffering state of the
45 // pipeline.
46 virtual void OnBufferingStateChange(BufferingState state) {}
47
48 // Executed whenever the presentation duration changes.
49 virtual void OnDurationChange() {}
50
51 // Executed whenever a text track is added.
52 virtual void OnAddTextTrack(const TextTrackConfig& config,
53 const AddTextTrackDoneCB& done_cb) {}
54
55 // Executed whenever the key needed to decrypt the stream is not available.
56 virtual void OnWaitingForDecryptionKey() {}
57 };
58
59 virtual ~Pipeline() {}
43 60
44 // Build a pipeline to using the given |demuxer| and |renderer| to construct 61 // 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. 62 // a filter chain, executing |seek_cb| when the initial seek has completed.
46 // 63 //
47 // The following permanent callbacks will be executed as follows up until 64 // The following permanent callbacks will be executed on PipelineClient up
48 // Stop() has completed: 65 // until Stop() has completed:
49 // |ended_cb| will be executed whenever the media reaches the end. 66 // OnError
50 // |error_cb| will be executed whenever an error occurs but hasn't been 67 // OnEnded
51 // reported already through another callback. 68 // OnMetadata
52 // |metadata_cb| will be executed when the content duration, container video 69 // OnBufferingStateChange
53 // size, start time, and whether the content has audio and/or 70 // OnDurationChange
54 // video in supported formats are known. 71 // OnAddTextTrack
55 // |buffering_state_cb| will be executed whenever there are changes in the 72 // OnWaitingForDecryptionKey
56 // overall buffering state of the pipeline. 73 //
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. 74 // It is an error to call this method after the pipeline has already started.
63 virtual void Start(Demuxer* demuxer, 75 virtual void Start(Demuxer* demuxer,
64 scoped_ptr<Renderer> renderer, 76 scoped_ptr<Renderer> renderer,
65 const base::Closure& ended_cb, 77 Client* client,
66 const PipelineStatusCB& error_cb, 78 const PipelineStatusCB& seek_cb) = 0;
xhwang 2016/04/25 22:49:45 Can you add a TODO about splitting |seek_cb|? You
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 79
74 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline 80 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline
75 // teardown has completed. 81 // teardown has completed.
76 // 82 //
77 // Stop() must complete before destroying the pipeline. It it permissible to 83 // Stop() must complete before destroying the pipeline. It it permissible to
78 // call Stop() at any point during the lifetime of the pipeline. 84 // call Stop() at any point during the lifetime of the pipeline.
79 // 85 //
80 // It is safe to delete the pipeline during the execution of |stop_cb|. 86 // It is safe to delete the pipeline during the execution of |stop_cb|.
81 virtual void Stop(const base::Closure& stop_cb) = 0; 87 virtual void Stop(const base::Closure& stop_cb) = 0;
82 88
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // Gets the current pipeline statistics. 159 // Gets the current pipeline statistics.
154 virtual PipelineStatistics GetStatistics() const = 0; 160 virtual PipelineStatistics GetStatistics() const = 0;
155 161
156 virtual void SetCdm(CdmContext* cdm_context, 162 virtual void SetCdm(CdmContext* cdm_context,
157 const CdmAttachedCB& cdm_attached_cb) = 0; 163 const CdmAttachedCB& cdm_attached_cb) = 0;
158 }; 164 };
159 165
160 } // namespace media 166 } // namespace media
161 167
162 #endif // MEDIA_BASE_PIPELINE_H_ 168 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698