OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "media/base/buffers.h" | 5 #include "media/base/buffers.h" |
6 #include "media/base/filter_host.h" | 6 #include "media/base/filter_host.h" |
7 #include "media/base/pipeline.h" | 7 #include "media/base/pipeline.h" |
8 #include "media/filters/video_renderer_base.h" | 8 #include "media/filters/video_renderer_base.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 27 matching lines...) Expand all Loading... |
38 submit_reads_task_(NULL), | 38 submit_reads_task_(NULL), |
39 preroll_complete_(false) { | 39 preroll_complete_(false) { |
40 } | 40 } |
41 | 41 |
42 VideoRendererBase::~VideoRendererBase() { | 42 VideoRendererBase::~VideoRendererBase() { |
43 Stop(); | 43 Stop(); |
44 } | 44 } |
45 | 45 |
46 // static | 46 // static |
47 bool VideoRendererBase::IsMediaFormatSupported( | 47 bool VideoRendererBase::IsMediaFormatSupported( |
48 const MediaFormat* media_format) { | 48 const MediaFormat& media_format) { |
49 int width; | 49 int width; |
50 int height; | 50 int height; |
51 return ParseMediaFormat(media_format, &width, &height); | 51 return ParseMediaFormat(media_format, &width, &height); |
52 } | 52 } |
53 | 53 |
54 // static | 54 // static |
55 bool VideoRendererBase::ParseMediaFormat(const MediaFormat* media_format, | 55 bool VideoRendererBase::ParseMediaFormat(const MediaFormat& media_format, |
56 int* width_out, | 56 int* width_out, |
57 int* height_out) { | 57 int* height_out) { |
58 DCHECK(media_format && width_out && height_out); | 58 DCHECK(width_out && height_out); |
59 std::string mime_type; | 59 std::string mime_type; |
60 return (media_format->GetAsString(MediaFormat::kMimeType, &mime_type) && | 60 return (media_format.GetAsString(MediaFormat::kMimeType, &mime_type) && |
61 mime_type.compare(mime_type::kUncompressedVideo) == 0 && | 61 mime_type.compare(mime_type::kUncompressedVideo) == 0 && |
62 media_format->GetAsInteger(MediaFormat::kWidth, width_out) && | 62 media_format.GetAsInteger(MediaFormat::kWidth, width_out) && |
63 media_format->GetAsInteger(MediaFormat::kHeight, height_out)); | 63 media_format.GetAsInteger(MediaFormat::kHeight, height_out)); |
64 } | 64 } |
65 | 65 |
66 void VideoRendererBase::Stop() { | 66 void VideoRendererBase::Stop() { |
67 OnStop(); | 67 OnStop(); |
68 AutoLock auto_lock(lock_); | 68 AutoLock auto_lock(lock_); |
69 DiscardAllFrames(); | 69 DiscardAllFrames(); |
70 if (submit_reads_task_) { | 70 if (submit_reads_task_) { |
71 // The task is owned by the message loop, so we don't delete it here. We | 71 // The task is owned by the message loop, so we don't delete it here. We |
72 // know the task won't call us because we canceled it, and we know we are | 72 // know the task won't call us because we canceled it, and we know we are |
73 // on the pipeline thread, since we're in the filter's Stop method, so there | 73 // on the pipeline thread, since we're in the filter's Stop method, so there |
74 // is no threading problem. Just let the task be run by the message loop | 74 // is no threading problem. Just let the task be run by the message loop |
75 // and then be killed. | 75 // and then be killed. |
76 submit_reads_task_->Cancel(); | 76 submit_reads_task_->Cancel(); |
77 submit_reads_task_ = NULL; | 77 submit_reads_task_ = NULL; |
78 } | 78 } |
79 decoder_ = NULL; | 79 decoder_ = NULL; |
80 } | 80 } |
81 | 81 |
82 bool VideoRendererBase::Initialize(VideoDecoder* decoder) { | 82 bool VideoRendererBase::Initialize(VideoDecoder* decoder) { |
83 int width, height; | 83 int width, height; |
84 decoder_ = decoder; | 84 decoder_ = decoder; |
85 if (ParseMediaFormat(decoder_->GetMediaFormat(), &width, &height) && | 85 if (ParseMediaFormat(decoder_->media_format(), &width, &height) && |
86 OnInitialize(width, height)) { | 86 OnInitialize(width, height)) { |
87 host_->SetVideoSize(width, height); | 87 host_->SetVideoSize(width, height); |
88 host_->SetTimeUpdateCallback( | 88 host_->SetTimeUpdateCallback( |
89 NewCallback(this, &VideoRendererBase::TimeUpdateCallback)); | 89 NewCallback(this, &VideoRendererBase::TimeUpdateCallback)); |
90 SubmitReads(); | 90 SubmitReads(); |
91 return true; | 91 return true; |
92 } | 92 } |
93 decoder_ = NULL; | 93 decoder_ = NULL; |
94 return false; | 94 return false; |
95 } | 95 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 (*frame_out)->GetDuration(); | 219 (*frame_out)->GetDuration(); |
220 } else { | 220 } else { |
221 time_next_frame = queue_[1]->GetTimestamp(); | 221 time_next_frame = queue_[1]->GetTimestamp(); |
222 } | 222 } |
223 } | 223 } |
224 host_->ScheduleTimeUpdateCallback(time_next_frame); | 224 host_->ScheduleTimeUpdateCallback(time_next_frame); |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 } // namespace | 228 } // namespace |
OLD | NEW |