OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "media/cast/cast_environment.h" | 5 #include "media/cast/cast_environment.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 using base::TaskRunner; | 9 using base::TaskRunner; |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 namespace cast { | 12 namespace cast { |
13 | 13 |
14 CastEnvironment::CastEnvironment( | 14 CastEnvironment::CastEnvironment( |
15 base::TickClock* clock, | 15 base::TickClock* clock, |
16 scoped_refptr<TaskRunner> main_thread_proxy, | 16 scoped_refptr<TaskRunner> main_thread_proxy, |
17 scoped_refptr<TaskRunner> audio_encode_thread_proxy, | 17 scoped_refptr<TaskRunner> audio_encode_thread_proxy, |
18 scoped_refptr<TaskRunner> audio_decode_thread_proxy, | 18 scoped_refptr<TaskRunner> audio_decode_thread_proxy, |
19 scoped_refptr<TaskRunner> video_encode_thread_proxy, | 19 scoped_refptr<TaskRunner> video_encode_thread_proxy, |
20 scoped_refptr<TaskRunner> video_decode_thread_proxy) | 20 scoped_refptr<TaskRunner> video_decode_thread_proxy, |
| 21 const CastLoggingConfig& config) |
21 : clock_(clock), | 22 : clock_(clock), |
22 main_thread_proxy_(main_thread_proxy), | 23 main_thread_proxy_(main_thread_proxy), |
23 audio_encode_thread_proxy_(audio_encode_thread_proxy), | 24 audio_encode_thread_proxy_(audio_encode_thread_proxy), |
24 audio_decode_thread_proxy_(audio_decode_thread_proxy), | 25 audio_decode_thread_proxy_(audio_decode_thread_proxy), |
25 video_encode_thread_proxy_(video_encode_thread_proxy), | 26 video_encode_thread_proxy_(video_encode_thread_proxy), |
26 video_decode_thread_proxy_(video_decode_thread_proxy) { | 27 video_decode_thread_proxy_(video_decode_thread_proxy), |
| 28 logging_(new LoggingImpl(clock, main_thread_proxy, config)) { |
27 DCHECK(main_thread_proxy) << "Main thread required"; | 29 DCHECK(main_thread_proxy) << "Main thread required"; |
28 } | 30 } |
29 | 31 |
30 CastEnvironment::~CastEnvironment() {} | 32 CastEnvironment::~CastEnvironment() {} |
31 | 33 |
32 bool CastEnvironment::PostTask(ThreadId identifier, | 34 bool CastEnvironment::PostTask(ThreadId identifier, |
33 const tracked_objects::Location& from_here, | 35 const tracked_objects::Location& from_here, |
34 const base::Closure& task) { | 36 const base::Closure& task) { |
35 scoped_refptr<TaskRunner> task_runner = | 37 scoped_refptr<TaskRunner> task_runner = |
36 GetMessageTaskRunnerForThread(identifier); | 38 GetMessageTaskRunnerForThread(identifier); |
(...skipping 18 matching lines...) Expand all Loading... |
55 return main_thread_proxy_; | 57 return main_thread_proxy_; |
56 case CastEnvironment::AUDIO_ENCODER: | 58 case CastEnvironment::AUDIO_ENCODER: |
57 return audio_encode_thread_proxy_; | 59 return audio_encode_thread_proxy_; |
58 case CastEnvironment::AUDIO_DECODER: | 60 case CastEnvironment::AUDIO_DECODER: |
59 return audio_decode_thread_proxy_; | 61 return audio_decode_thread_proxy_; |
60 case CastEnvironment::VIDEO_ENCODER: | 62 case CastEnvironment::VIDEO_ENCODER: |
61 return video_encode_thread_proxy_; | 63 return video_encode_thread_proxy_; |
62 case CastEnvironment::VIDEO_DECODER: | 64 case CastEnvironment::VIDEO_DECODER: |
63 return video_decode_thread_proxy_; | 65 return video_decode_thread_proxy_; |
64 default: | 66 default: |
65 NOTREACHED() << "Invalid Thread ID."; | 67 NOTREACHED() << "Invalid Thread identifier"; |
66 return NULL; | 68 return NULL; |
67 } | 69 } |
68 } | 70 } |
69 | 71 |
70 bool CastEnvironment::CurrentlyOn(ThreadId identifier) { | 72 bool CastEnvironment::CurrentlyOn(ThreadId identifier) { |
71 switch (identifier) { | 73 switch (identifier) { |
72 case CastEnvironment::MAIN: | 74 case CastEnvironment::MAIN: |
73 return main_thread_proxy_->RunsTasksOnCurrentThread(); | 75 return main_thread_proxy_->RunsTasksOnCurrentThread(); |
74 case CastEnvironment::AUDIO_ENCODER: | 76 case CastEnvironment::AUDIO_ENCODER: |
75 return audio_encode_thread_proxy_->RunsTasksOnCurrentThread(); | 77 return audio_encode_thread_proxy_->RunsTasksOnCurrentThread(); |
76 case CastEnvironment::AUDIO_DECODER: | 78 case CastEnvironment::AUDIO_DECODER: |
77 return audio_decode_thread_proxy_->RunsTasksOnCurrentThread(); | 79 return audio_decode_thread_proxy_->RunsTasksOnCurrentThread(); |
78 case CastEnvironment::VIDEO_ENCODER: | 80 case CastEnvironment::VIDEO_ENCODER: |
79 return video_encode_thread_proxy_->RunsTasksOnCurrentThread(); | 81 return video_encode_thread_proxy_->RunsTasksOnCurrentThread(); |
80 case CastEnvironment::VIDEO_DECODER: | 82 case CastEnvironment::VIDEO_DECODER: |
81 return video_decode_thread_proxy_->RunsTasksOnCurrentThread(); | 83 return video_decode_thread_proxy_->RunsTasksOnCurrentThread(); |
82 default: | 84 default: |
83 NOTREACHED() << "Wrong thread identifier"; | 85 NOTREACHED() << "Invalid thread identifier"; |
84 return false; | 86 return false; |
85 } | 87 } |
86 } | 88 } |
87 | 89 |
88 base::TickClock* CastEnvironment::Clock() { | 90 base::TickClock* CastEnvironment::Clock() const { |
89 return clock_; | 91 return clock_; |
90 } | 92 } |
91 | 93 |
| 94 LoggingImpl* CastEnvironment::Logging() { |
| 95 DCHECK(CurrentlyOn(CastEnvironment::MAIN)) << |
| 96 "Must be called from main thread"; |
| 97 return logging_.get(); |
| 98 } |
| 99 |
92 } // namespace cast | 100 } // namespace cast |
93 } // namespace media | 101 } // namespace media |
OLD | NEW |