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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // Initialization is a series of state transitions from "Created" through each | 56 // Initialization is a series of state transitions from "Created" through each |
57 // filter initialization state. When all filter initialization states have | 57 // filter initialization state. When all filter initialization states have |
58 // completed, we are implicitly in a "Paused" state. At that point we simulate | 58 // completed, we are implicitly in a "Paused" state. At that point we simulate |
59 // a Seek() to the beginning of the media to give filters a chance to preroll. | 59 // a Seek() to the beginning of the media to give filters a chance to preroll. |
60 // From then on the normal Seek() transitions are carried out and we start | 60 // From then on the normal Seek() transitions are carried out and we start |
61 // playing the media. | 61 // playing the media. |
62 // | 62 // |
63 // If any error ever happens, this object will transition to the "Error" state | 63 // If any error ever happens, this object will transition to the "Error" state |
64 // from any state. If Stop() is ever called, this object will transition to | 64 // from any state. If Stop() is ever called, this object will transition to |
65 // "Stopped" state. | 65 // "Stopped" state. |
66 class MEDIA_EXPORT Pipeline | 66 class MEDIA_EXPORT Pipeline : public DemuxerHost { |
67 : public base::RefCountedThreadSafe<Pipeline>, | |
68 public DemuxerHost { | |
69 public: | 67 public: |
70 // Buffering states the pipeline transitions between during playback. | 68 // Buffering states the pipeline transitions between during playback. |
71 // kHaveMetadata: | 69 // kHaveMetadata: |
72 // Indicates that the following things are known: | 70 // Indicates that the following things are known: |
73 // content duration, natural size, start time, and whether the content has | 71 // content duration, natural size, start time, and whether the content has |
74 // audio and/or video in supported formats. | 72 // audio and/or video in supported formats. |
75 // kPrerollCompleted: | 73 // kPrerollCompleted: |
76 // All renderers have buffered enough data to satisfy preroll and are ready | 74 // All renderers have buffered enough data to satisfy preroll and are ready |
77 // to start playback. | 75 // to start playback. |
78 enum BufferingState { | 76 enum BufferingState { |
79 kHaveMetadata, | 77 kHaveMetadata, |
80 kPrerollCompleted, | 78 kPrerollCompleted, |
81 }; | 79 }; |
82 | 80 |
83 typedef base::Callback<void(BufferingState)> BufferingStateCB; | 81 typedef base::Callback<void(BufferingState)> BufferingStateCB; |
84 | 82 |
85 // Constructs a media pipeline that will execute on |message_loop|. | 83 // Constructs a media pipeline that will execute on |message_loop|. |
86 Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, | 84 Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, |
87 MediaLog* media_log); | 85 MediaLog* media_log); |
| 86 virtual ~Pipeline(); |
88 | 87 |
89 // Build a pipeline to using the given filter collection to construct a filter | 88 // Build a pipeline to using the given filter collection to construct a filter |
90 // chain, executing |seek_cb| when the initial seek/preroll has completed. | 89 // chain, executing |seek_cb| when the initial seek/preroll has completed. |
91 // | 90 // |
92 // |filter_collection| must be a complete collection containing a demuxer, | 91 // |filter_collection| must be a complete collection containing a demuxer, |
93 // audio/video decoders, and audio/video renderers. Failing to do so will | 92 // audio/video decoders, and audio/video renderers. Failing to do so will |
94 // result in a crash. | 93 // result in a crash. |
95 // | 94 // |
96 // The following permanent callbacks will be executed as follows up until | 95 // The following permanent callbacks will be executed as follows up until |
97 // Stop() has completed: | 96 // Stop() has completed: |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 void SetErrorForTesting(PipelineStatus status); | 190 void SetErrorForTesting(PipelineStatus status); |
192 | 191 |
193 private: | 192 private: |
194 FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges); | 193 FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges); |
195 FRIEND_TEST_ALL_PREFIXES(PipelineTest, DisableAudioRenderer); | 194 FRIEND_TEST_ALL_PREFIXES(PipelineTest, DisableAudioRenderer); |
196 FRIEND_TEST_ALL_PREFIXES(PipelineTest, DisableAudioRendererDuringInit); | 195 FRIEND_TEST_ALL_PREFIXES(PipelineTest, DisableAudioRendererDuringInit); |
197 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback); | 196 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback); |
198 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo); | 197 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo); |
199 friend class MediaLog; | 198 friend class MediaLog; |
200 | 199 |
201 // Only allow ourselves to be deleted by reference counting. | |
202 friend class base::RefCountedThreadSafe<Pipeline>; | |
203 virtual ~Pipeline(); | |
204 | |
205 // Pipeline states, as described above. | 200 // Pipeline states, as described above. |
206 enum State { | 201 enum State { |
207 kCreated, | 202 kCreated, |
208 kInitDemuxer, | 203 kInitDemuxer, |
209 kInitAudioRenderer, | 204 kInitAudioRenderer, |
210 kInitVideoRenderer, | 205 kInitVideoRenderer, |
211 kInitPrerolling, | 206 kInitPrerolling, |
212 kSeeking, | 207 kSeeking, |
213 kStarting, | 208 kStarting, |
214 kStarted, | 209 kStarted, |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 scoped_ptr<SerialRunner> pending_callbacks_; | 442 scoped_ptr<SerialRunner> pending_callbacks_; |
448 | 443 |
449 base::ThreadChecker thread_checker_; | 444 base::ThreadChecker thread_checker_; |
450 | 445 |
451 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 446 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
452 }; | 447 }; |
453 | 448 |
454 } // namespace media | 449 } // namespace media |
455 | 450 |
456 #endif // MEDIA_BASE_PIPELINE_H_ | 451 #endif // MEDIA_BASE_PIPELINE_H_ |
OLD | NEW |