OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/bind.h" | |
6 #include "base/logging.h" | |
7 #include "media/tools/player_x11/data_source_logger.h" | |
8 | |
9 static void LogAndRunReadCB( | |
10 int64 position, int size, | |
11 const media::DataSource::ReadCB& read_cb, int result) { | |
12 VLOG(1) << "Read(" << position << ", " << size << ") -> " << result; | |
13 read_cb.Run(result); | |
14 } | |
15 | |
16 DataSourceLogger::DataSourceLogger( | |
17 scoped_ptr<media::DataSource> data_source, | |
18 bool streaming) | |
19 : data_source_(data_source.Pass()), | |
20 streaming_(streaming) { | |
21 } | |
22 | |
23 void DataSourceLogger::Stop() { | |
24 VLOG(1) << "Stop()"; | |
25 data_source_->Stop(); | |
26 } | |
27 | |
28 void DataSourceLogger::Read( | |
29 int64 position, int size, uint8* data, | |
30 const media::DataSource::ReadCB& read_cb) { | |
31 VLOG(1) << "Read(" << position << ", " << size << ")"; | |
32 data_source_->Read(position, size, data, base::Bind( | |
33 &LogAndRunReadCB, position, size, read_cb)); | |
34 } | |
35 | |
36 bool DataSourceLogger::GetSize(int64* size_out) { | |
37 bool success = data_source_->GetSize(size_out); | |
38 VLOG(1) << "GetSize() -> " << (success ? "true" : "false") | |
39 << ", " << *size_out; | |
40 return success; | |
41 } | |
42 | |
43 bool DataSourceLogger::IsStreaming() { | |
44 if (streaming_) { | |
45 VLOG(1) << "IsStreaming() -> true (overridden)"; | |
46 return true; | |
47 } | |
48 | |
49 bool streaming = data_source_->IsStreaming(); | |
50 VLOG(1) << "IsStreaming() -> " << (streaming ? "true" : "false"); | |
51 return streaming; | |
52 } | |
53 | |
54 void DataSourceLogger::SetBitrate(int bitrate) { | |
55 VLOG(1) << "SetBitrate(" << bitrate << ")"; | |
56 data_source_->SetBitrate(bitrate); | |
57 } | |
58 | |
59 DataSourceLogger::~DataSourceLogger() {} | |
OLD | NEW |