15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef MEDIA_TOOLS_PLAYER_X11_DATA_SOURCE_LOGGER_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define MEDIA_TOOLS_PLAYER_X11_DATA_SOURCE_LOGGER_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "media/base/data_source.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Logs all DataSource operations to VLOG(1) for debugging purposes. 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DataSourceLogger : public media::DataSource { 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Constructs a DataSourceLogger to log operations against another DataSource. 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |data_source| must be initialized in advance. 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |streaming| when set to true will override the implementation 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // IsStreaming() to always return true, otherwise it will delegate to 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |data_source|. 20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) DataSourceLogger(scoped_ptr<DataSource> data_source, 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool force_streaming); 22c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual ~DataSourceLogger(); 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // media::DataSource implementation. 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void set_host(media::DataSourceHost* host) OVERRIDE; 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Stop(const base::Closure& closure) OVERRIDE; 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Read( 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int64 position, int size, uint8* data, 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const media::DataSource::ReadCB& read_cb) OVERRIDE; 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool GetSize(int64* size_out) OVERRIDE; 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsStreaming() OVERRIDE; 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetBitrate(int bitrate) OVERRIDE; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 35c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<media::DataSource> data_source_; 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool streaming_; 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(DataSourceLogger); 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // MEDIA_TOOLS_PLAYER_X11_DATA_SOURCE_LOGGER_H_ 42