| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // Initialization is a series of state transitions from "Created" through each | 83 // Initialization is a series of state transitions from "Created" through each |
| 84 // filter initialization state. When all filter initialization states have | 84 // filter initialization state. When all filter initialization states have |
| 85 // completed, we are implicitly in a "Paused" state. At that point we simulate | 85 // completed, we are implicitly in a "Paused" state. At that point we simulate |
| 86 // a Seek() to the beginning of the media to give filters a chance to preroll. | 86 // a Seek() to the beginning of the media to give filters a chance to preroll. |
| 87 // From then on the normal Seek() transitions are carried out and we start | 87 // From then on the normal Seek() transitions are carried out and we start |
| 88 // playing the media. | 88 // playing the media. |
| 89 // | 89 // |
| 90 // If any error ever happens, this object will transition to the "Error" state | 90 // If any error ever happens, this object will transition to the "Error" state |
| 91 // from any state. If Stop() is ever called, this object will transition to | 91 // from any state. If Stop() is ever called, this object will transition to |
| 92 // "Stopped" state. | 92 // "Stopped" state. |
| 93 class MEDIA_EXPORT Pipeline | 93 class MEDIA_EXPORT Pipeline : public DemuxerHost { |
| 94 : public base::RefCountedThreadSafe<Pipeline>, | |
| 95 public DemuxerHost { | |
| 96 public: | 94 public: |
| 97 // Buffering states the pipeline transitions between during playback. | 95 // Buffering states the pipeline transitions between during playback. |
| 98 // kHaveMetadata: | 96 // kHaveMetadata: |
| 99 // Indicates that the following things are known: | 97 // Indicates that the following things are known: |
| 100 // content duration, natural size, start time, and whether the content has | 98 // content duration, natural size, start time, and whether the content has |
| 101 // audio and/or video in supported formats. | 99 // audio and/or video in supported formats. |
| 102 // kPrerollCompleted: | 100 // kPrerollCompleted: |
| 103 // All renderers have buffered enough data to satisfy preroll and are ready | 101 // All renderers have buffered enough data to satisfy preroll and are ready |
| 104 // to start playback. | 102 // to start playback. |
| 105 enum BufferingState { | 103 enum BufferingState { |
| 106 kHaveMetadata, | 104 kHaveMetadata, |
| 107 kPrerollCompleted, | 105 kPrerollCompleted, |
| 108 }; | 106 }; |
| 109 | 107 |
| 110 typedef base::Callback<void(BufferingState)> BufferingStateCB; | 108 typedef base::Callback<void(BufferingState)> BufferingStateCB; |
| 111 | 109 |
| 112 // Constructs a media pipeline that will execute on |message_loop|. | 110 // Constructs a media pipeline that will execute on |message_loop|. |
| 113 Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, | 111 Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| 114 MediaLog* media_log); | 112 MediaLog* media_log); |
| 113 virtual ~Pipeline(); |
| 115 | 114 |
| 116 // Build a pipeline to using the given filter collection to construct a filter | 115 // Build a pipeline to using the given filter collection to construct a filter |
| 117 // chain, executing |seek_cb| when the initial seek/preroll has completed. | 116 // chain, executing |seek_cb| when the initial seek/preroll has completed. |
| 118 // | 117 // |
| 119 // |filter_collection| must be a complete collection containing a demuxer, | 118 // |filter_collection| must be a complete collection containing a demuxer, |
| 120 // audio/video decoders, and audio/video renderers. Failing to do so will | 119 // audio/video decoders, and audio/video renderers. Failing to do so will |
| 121 // result in a crash. | 120 // result in a crash. |
| 122 // | 121 // |
| 123 // The following permanent callbacks will be executed as follows up until | 122 // The following permanent callbacks will be executed as follows up until |
| 124 // Stop() has completed: | 123 // Stop() has completed: |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 void SetErrorForTesting(PipelineStatus status); | 217 void SetErrorForTesting(PipelineStatus status); |
| 219 | 218 |
| 220 private: | 219 private: |
| 221 FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges); | 220 FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges); |
| 222 FRIEND_TEST_ALL_PREFIXES(PipelineTest, DisableAudioRenderer); | 221 FRIEND_TEST_ALL_PREFIXES(PipelineTest, DisableAudioRenderer); |
| 223 FRIEND_TEST_ALL_PREFIXES(PipelineTest, DisableAudioRendererDuringInit); | 222 FRIEND_TEST_ALL_PREFIXES(PipelineTest, DisableAudioRendererDuringInit); |
| 224 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback); | 223 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback); |
| 225 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo); | 224 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo); |
| 226 friend class MediaLog; | 225 friend class MediaLog; |
| 227 | 226 |
| 228 // Only allow ourselves to be deleted by reference counting. | |
| 229 friend class base::RefCountedThreadSafe<Pipeline>; | |
| 230 virtual ~Pipeline(); | |
| 231 | |
| 232 // Pipeline states, as described above. | 227 // Pipeline states, as described above. |
| 233 enum State { | 228 enum State { |
| 234 kCreated, | 229 kCreated, |
| 235 kInitDemuxer, | 230 kInitDemuxer, |
| 236 kInitAudioRenderer, | 231 kInitAudioRenderer, |
| 237 kInitVideoRenderer, | 232 kInitVideoRenderer, |
| 238 kInitPrerolling, | 233 kInitPrerolling, |
| 239 kSeeking, | 234 kSeeking, |
| 240 kStarting, | 235 kStarting, |
| 241 kStarted, | 236 kStarted, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 scoped_ptr<SerialRunner> pending_callbacks_; | 469 scoped_ptr<SerialRunner> pending_callbacks_; |
| 475 | 470 |
| 476 base::ThreadChecker thread_checker_; | 471 base::ThreadChecker thread_checker_; |
| 477 | 472 |
| 478 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 473 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
| 479 }; | 474 }; |
| 480 | 475 |
| 481 } // namespace media | 476 } // namespace media |
| 482 | 477 |
| 483 #endif // MEDIA_BASE_PIPELINE_H_ | 478 #endif // MEDIA_BASE_PIPELINE_H_ |
| OLD | NEW |