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

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

Issue 7584013: Log PipelineImpl events to MediaLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase atop _and_diff_against_ 759001. Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Implementation of Pipeline & PipelineStatusNotification (an async-to-sync 5 // Implementation of Pipeline & PipelineStatusNotification (an async-to-sync
6 // callback adapter). 6 // callback adapter).
7 7
8 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ 8 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_
9 #define MEDIA_BASE_PIPELINE_IMPL_H_ 9 #define MEDIA_BASE_PIPELINE_IMPL_H_
10 10
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/message_loop.h" 18 #include "base/message_loop.h"
19 #include "base/synchronization/condition_variable.h" 19 #include "base/synchronization/condition_variable.h"
20 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
21 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
22 #include "base/time.h" 22 #include "base/time.h"
23 #include "media/base/clock.h" 23 #include "media/base/clock.h"
24 #include "media/base/composite_filter.h" 24 #include "media/base/composite_filter.h"
25 #include "media/base/filter_host.h" 25 #include "media/base/filter_host.h"
26 #include "media/base/pipeline.h" 26 #include "media/base/pipeline.h"
27 27
28 namespace media { 28 namespace media {
29 29
30 class MediaLog;
31
30 // Adapter for using asynchronous Pipeline methods in code that wants to run 32 // Adapter for using asynchronous Pipeline methods in code that wants to run
31 // synchronously. To use, construct an instance of this class and pass the 33 // synchronously. To use, construct an instance of this class and pass the
32 // |Callback()| to the Pipeline method requiring a callback. Then Wait() for 34 // |Callback()| to the Pipeline method requiring a callback. Then Wait() for
33 // the callback to get fired and call status() to see what the callback's 35 // the callback to get fired and call status() to see what the callback's
34 // argument was. This object is for one-time use; call |Callback()| exactly 36 // argument was. This object is for one-time use; call |Callback()| exactly
35 // once. 37 // once.
36 class PipelineStatusNotification { 38 class PipelineStatusNotification {
37 public: 39 public:
38 PipelineStatusNotification(); 40 PipelineStatusNotification();
39 ~PipelineStatusNotification(); 41 ~PipelineStatusNotification();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // completed, we are implicitly in a "Paused" state. At that point we simulate 88 // completed, we are implicitly in a "Paused" state. At that point we simulate
87 // a Seek() to the beginning of the media to give filters a chance to preroll. 89 // a Seek() to the beginning of the media to give filters a chance to preroll.
88 // From then on the normal Seek() transitions are carried out and we start 90 // From then on the normal Seek() transitions are carried out and we start
89 // playing the media. 91 // playing the media.
90 // 92 //
91 // If any error ever happens, this object will transition to the "Error" state 93 // If any error ever happens, this object will transition to the "Error" state
92 // from any state. If Stop() is ever called, this object will transition to 94 // from any state. If Stop() is ever called, this object will transition to
93 // "Stopped" state. 95 // "Stopped" state.
94 class PipelineImpl : public Pipeline, public FilterHost { 96 class PipelineImpl : public Pipeline, public FilterHost {
95 public: 97 public:
96 explicit PipelineImpl(MessageLoop* message_loop); 98 explicit PipelineImpl(MessageLoop* message_loop, MediaLog* media_log);
97 99
98 // Pipeline implementation. 100 // Pipeline implementation.
99 virtual void Init(PipelineStatusCallback* ended_callback, 101 virtual void Init(PipelineStatusCallback* ended_callback,
100 PipelineStatusCallback* error_callback, 102 PipelineStatusCallback* error_callback,
101 PipelineStatusCallback* network_callback); 103 PipelineStatusCallback* network_callback);
102 virtual bool Start(FilterCollection* filter_collection, 104 virtual bool Start(FilterCollection* filter_collection,
103 const std::string& uri, 105 const std::string& uri,
104 PipelineStatusCallback* start_callback); 106 PipelineStatusCallback* start_callback);
105 virtual void Stop(PipelineStatusCallback* stop_callback); 107 virtual void Stop(PipelineStatusCallback* stop_callback);
106 virtual void Seek(base::TimeDelta time, 108 virtual void Seek(base::TimeDelta time,
(...skipping 14 matching lines...) Expand all
121 virtual int64 GetBufferedBytes() const; 123 virtual int64 GetBufferedBytes() const;
122 virtual int64 GetTotalBytes() const; 124 virtual int64 GetTotalBytes() const;
123 virtual void GetVideoSize(size_t* width_out, size_t* height_out) const; 125 virtual void GetVideoSize(size_t* width_out, size_t* height_out) const;
124 virtual bool IsStreaming() const; 126 virtual bool IsStreaming() const;
125 virtual bool IsLoaded() const; 127 virtual bool IsLoaded() const;
126 virtual PipelineStatistics GetStatistics() const; 128 virtual PipelineStatistics GetStatistics() const;
127 129
128 void SetClockForTesting(Clock* clock); 130 void SetClockForTesting(Clock* clock);
129 131
130 private: 132 private:
133 friend class MediaLog;
134
131 // Pipeline states, as described above. 135 // Pipeline states, as described above.
132 enum State { 136 enum State {
133 kCreated, 137 kCreated,
134 kInitDemuxer, 138 kInitDemuxer,
135 kInitAudioDecoder, 139 kInitAudioDecoder,
136 kInitAudioRenderer, 140 kInitAudioRenderer,
137 kInitVideoDecoder, 141 kInitVideoDecoder,
138 kInitVideoRenderer, 142 kInitVideoRenderer,
139 kPausing, 143 kPausing,
140 kSeeking, 144 kSeeking,
141 kFlushing, 145 kFlushing,
142 kStarting, 146 kStarting,
143 kStarted, 147 kStarted,
144 kEnded, 148 kEnded,
145 kStopping, 149 kStopping,
146 kStopped, 150 kStopped,
147 kError, 151 kError,
148 }; 152 };
149 153
150 virtual ~PipelineImpl(); 154 virtual ~PipelineImpl();
151 155
152 // Reset the state of the pipeline object to the initial state. This method 156 // Reset the state of the pipeline object to the initial state. This method
153 // is used by the constructor, and the Stop() method. 157 // is used by the constructor, and the Stop() method.
154 void ResetState(); 158 void ResetState();
155 159
156 // Updates |state_|. All state transitions should use this call. 160 // Updates |state_|. All state transitions should use this call.
157 void set_state(State next_state); 161 void SetState(State next_state);
158 162
159 // Simple method used to make sure the pipeline is running normally. 163 // Simple method used to make sure the pipeline is running normally.
160 bool IsPipelineOk(); 164 bool IsPipelineOk();
161 165
162 // Helper method to tell whether we are stopped or in error. 166 // Helper method to tell whether we are stopped or in error.
163 bool IsPipelineStopped(); 167 bool IsPipelineStopped();
164 168
165 // Helper method to tell whether we are in transition to stop state. 169 // Helper method to tell whether we are in transition to stop state.
166 bool IsPipelineTearingDown(); 170 bool IsPipelineTearingDown();
167 171
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // This will remove the race condition during stop between filters. 311 // This will remove the race condition during stop between filters.
308 void TearDownPipeline(); 312 void TearDownPipeline();
309 313
310 // Compute the current time. Assumes that the lock has been acquired by the 314 // Compute the current time. Assumes that the lock has been acquired by the
311 // caller. 315 // caller.
312 base::TimeDelta GetCurrentTime_Locked() const; 316 base::TimeDelta GetCurrentTime_Locked() const;
313 317
314 // Message loop used to execute pipeline tasks. 318 // Message loop used to execute pipeline tasks.
315 MessageLoop* message_loop_; 319 MessageLoop* message_loop_;
316 320
321 // MediaLog to which to log events.
322 scoped_refptr<MediaLog> media_log_;
323
317 // Lock used to serialize access for the following data members. 324 // Lock used to serialize access for the following data members.
318 mutable base::Lock lock_; 325 mutable base::Lock lock_;
319 326
320 // Whether or not the pipeline is running. 327 // Whether or not the pipeline is running.
321 bool running_; 328 bool running_;
322 329
323 // Whether or not the pipeline is in transition for a seek operation. 330 // Whether or not the pipeline is in transition for a seek operation.
324 bool seek_pending_; 331 bool seek_pending_;
325 332
326 // Whether or not the pipeline is pending a stop operation. 333 // Whether or not the pipeline is pending a stop operation.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 PipelineStatistics statistics_; 462 PipelineStatistics statistics_;
456 463
457 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); 464 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime);
458 465
459 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); 466 DISALLOW_COPY_AND_ASSIGN(PipelineImpl);
460 }; 467 };
461 468
462 } // namespace media 469 } // namespace media
463 470
464 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ 471 #endif // MEDIA_BASE_PIPELINE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698