| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "media/base/filter_host.h" | 8 #include "media/base/filter_host.h" |
| 9 #include "media/filters/ffmpeg_common.h" | 9 #include "media/filters/ffmpeg_common.h" |
| 10 #include "media/filters/ffmpeg_demuxer.h" | 10 #include "media/filters/ffmpeg_demuxer.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 | 165 |
| 166 // | 166 // |
| 167 // FFmpegDemuxer | 167 // FFmpegDemuxer |
| 168 // | 168 // |
| 169 FFmpegDemuxer::FFmpegDemuxer() | 169 FFmpegDemuxer::FFmpegDemuxer() |
| 170 : thread_("DemuxerThread") { | 170 : thread_("DemuxerThread") { |
| 171 } | 171 } |
| 172 | 172 |
| 173 FFmpegDemuxer::~FFmpegDemuxer() { | 173 FFmpegDemuxer::~FFmpegDemuxer() { |
| 174 Stop(); | 174 DCHECK(!thread_.IsRunning()); |
| 175 DCHECK(!format_context_.get()); |
| 175 // TODO(scherkus): I believe we need to use av_close_input_file() here | 176 // TODO(scherkus): I believe we need to use av_close_input_file() here |
| 176 // instead of scoped_ptr_malloc calling av_free(). | 177 // instead of scoped_ptr_malloc calling av_free(). |
| 177 // | 178 // |
| 178 // Note that av_close_input_file() doesn't close the codecs so we need to | 179 // Note that av_close_input_file() doesn't close the codecs so we need to |
| 179 // figure out who's responsible for closing the them. | 180 // figure out who's responsible for closing the them. |
| 180 } | 181 } |
| 181 | 182 |
| 182 void FFmpegDemuxer::PostDemuxTask() { | 183 void FFmpegDemuxer::PostDemuxTask() { |
| 183 thread_.message_loop()->PostTask(FROM_HERE, | 184 thread_.message_loop()->PostTask(FROM_HERE, |
| 184 NewRunnableMethod(this, &FFmpegDemuxer::DemuxTask)); | 185 NewRunnableMethod(this, &FFmpegDemuxer::DemuxTask)); |
| 185 } | 186 } |
| 186 | 187 |
| 187 void FFmpegDemuxer::Stop() { | 188 void FFmpegDemuxer::Stop() { |
| 188 thread_.Stop(); | 189 thread_.Stop(); |
| 190 format_context_.reset(); |
| 189 } | 191 } |
| 190 | 192 |
| 191 void FFmpegDemuxer::Seek(base::TimeDelta time) { | 193 void FFmpegDemuxer::Seek(base::TimeDelta time) { |
| 192 // TODO(hclam): by returning from this method, it is assumed that the seek | 194 // TODO(hclam): by returning from this method, it is assumed that the seek |
| 193 // operation is completed and filters behind the demuxer is good to issue | 195 // operation is completed and filters behind the demuxer is good to issue |
| 194 // more reads, but we are posting a task here, which makes the seek operation | 196 // more reads, but we are posting a task here, which makes the seek operation |
| 195 // asynchronous, should change how seek works to make it fully asynchronous. | 197 // asynchronous, should change how seek works to make it fully asynchronous. |
| 196 thread_.message_loop()->PostTask(FROM_HERE, | 198 thread_.message_loop()->PostTask(FROM_HERE, |
| 197 NewRunnableMethod(this, &FFmpegDemuxer::SeekTask, time)); | 199 NewRunnableMethod(this, &FFmpegDemuxer::SeekTask, time)); |
| 198 } | 200 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 390 } |
| 389 DCHECK_EQ(clone->size, packet->size); | 391 DCHECK_EQ(clone->size, packet->size); |
| 390 clone->dts = packet->dts; | 392 clone->dts = packet->dts; |
| 391 clone->pts = packet->pts; | 393 clone->pts = packet->pts; |
| 392 clone->duration = packet->duration; | 394 clone->duration = packet->duration; |
| 393 memcpy(clone->data, packet->data, clone->size); | 395 memcpy(clone->data, packet->data, clone->size); |
| 394 return clone.release(); | 396 return clone.release(); |
| 395 } | 397 } |
| 396 | 398 |
| 397 } // namespace media | 399 } // namespace media |
| OLD | NEW |