Refactor ViEFilePlayer.
Types and arguments will be done in a later CL. Review URL: http://webrtc-codereview.appspot.com/324002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1180 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
e6f64835a0
commit
7991c0501f
File diff suppressed because it is too large
Load Diff
@ -8,117 +8,131 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*
|
||||
* vie_file_player.h
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_FILE_PLAYER_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_FILE_PLAYER_H_
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_VIE_FILE_PLAYER_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_VIE_FILE_PLAYER_H_
|
||||
|
||||
#include "common_types.h"
|
||||
#include "modules/media_file/interface/media_file_defines.h"
|
||||
#include "system_wrappers/interface/file_wrapper.h"
|
||||
#include "system_wrappers/interface/list_wrapper.h"
|
||||
#include "typedefs.h"
|
||||
#include "common_types.h" // webrtc::OutStream
|
||||
#include "file_player.h"
|
||||
#include "media_file_defines.h"
|
||||
#include "vie_file.h"
|
||||
#include "voe_file.h"
|
||||
#include "voe_video_sync.h"
|
||||
#include "list_wrapper.h"
|
||||
#include "vie_frame_provider_base.h"
|
||||
#include "file_wrapper.h"
|
||||
#include "video_engine/vie_frame_provider_base.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
class EventWrapper;
|
||||
class FilePlayer;
|
||||
class ThreadWrapper;
|
||||
class ViEFileObserver;
|
||||
class ViEInputManager;
|
||||
class ViEFilePlayer: public ViEFrameProviderBase,
|
||||
protected webrtc::FileCallback,
|
||||
protected webrtc::InStream // for audio
|
||||
{
|
||||
public:
|
||||
static ViEFilePlayer *CreateViEFilePlayer(int fileId, int engineId,
|
||||
const char* fileNameUTF8,
|
||||
const bool loop,
|
||||
const webrtc::FileFormats fileFormat,
|
||||
ViEInputManager& inputManager,
|
||||
VoiceEngine* vePtr);
|
||||
class VoEFile;
|
||||
class VoEVideoSync;
|
||||
class VoiceEngine;
|
||||
|
||||
static int GetFileInformation(const int engineId,
|
||||
const char* fileName,
|
||||
webrtc::VideoCodec& videoCodec,
|
||||
webrtc::CodecInst& audioCodec,
|
||||
const webrtc::FileFormats fileFormat);
|
||||
~ViEFilePlayer();
|
||||
class ViEFilePlayer
|
||||
: public ViEFrameProviderBase,
|
||||
protected FileCallback,
|
||||
protected InStream {
|
||||
public:
|
||||
static ViEFilePlayer* CreateViEFilePlayer(int file_id,
|
||||
int engine_id,
|
||||
const char* file_nameUTF8,
|
||||
const bool loop,
|
||||
const FileFormats file_format,
|
||||
ViEInputManager& input_manager,
|
||||
VoiceEngine* voe_ptr);
|
||||
|
||||
bool IsObserverRegistered();
|
||||
int RegisterObserver(ViEFileObserver& observer);
|
||||
int DeRegisterObserver();
|
||||
int SendAudioOnChannel(const int audioChannel, bool mixMicrophone,
|
||||
float volumeScaling);
|
||||
int StopSendAudioOnChannel(const int audioChannel);
|
||||
int PlayAudioLocally(const int audioChannel, float volumeScaling);
|
||||
int StopPlayAudioLocally(const int audioChannel);
|
||||
static int GetFileInformation(const int engine_id,
|
||||
const char* file_name,
|
||||
VideoCodec& video_codec,
|
||||
CodecInst& audio_codec,
|
||||
const FileFormats file_format);
|
||||
~ViEFilePlayer();
|
||||
|
||||
//Implement ViEFrameProviderBase
|
||||
virtual int FrameCallbackChanged();
|
||||
bool IsObserverRegistered();
|
||||
int RegisterObserver(ViEFileObserver& observer);
|
||||
int DeRegisterObserver();
|
||||
int SendAudioOnChannel(const int audio_channel,
|
||||
bool mix_microphone,
|
||||
float volume_scaling);
|
||||
int StopSendAudioOnChannel(const int audio_channel);
|
||||
int PlayAudioLocally(const int audio_channel, float volume_scaling);
|
||||
int StopPlayAudioLocally(const int audio_channel);
|
||||
|
||||
protected:
|
||||
ViEFilePlayer(int Id, int engineId, ViEInputManager& inputManager);
|
||||
int Init(const WebRtc_Word8* fileNameUTF8, const bool loop,
|
||||
const webrtc::FileFormats fileFormat, VoiceEngine* vePtr);
|
||||
int StopPlay();
|
||||
int StopPlayAudio();
|
||||
// Implements ViEFrameProviderBase.
|
||||
virtual int FrameCallbackChanged();
|
||||
|
||||
// File play decode function.
|
||||
static bool FilePlayDecodeThreadFunction(void* obj);
|
||||
bool FilePlayDecodeProcess();
|
||||
bool NeedsAudioFromFile(void* buf);
|
||||
protected:
|
||||
ViEFilePlayer(int Id, int engine_id, ViEInputManager& input_manager);
|
||||
int Init(const WebRtc_Word8* file_nameUTF8,
|
||||
const bool loop,
|
||||
const FileFormats file_format,
|
||||
VoiceEngine* voe_ptr);
|
||||
int StopPlay();
|
||||
int StopPlayAudio();
|
||||
|
||||
// From webrtc::InStream
|
||||
virtual int Read(void *buf, int len);
|
||||
virtual int Rewind() { return 0;}
|
||||
// File play decode function.
|
||||
static bool FilePlayDecodeThreadFunction(void* obj);
|
||||
bool FilePlayDecodeProcess();
|
||||
bool NeedsAudioFromFile(void* buf);
|
||||
|
||||
// From FileCallback
|
||||
virtual void PlayNotification(const WebRtc_Word32 /*id*/,
|
||||
const WebRtc_UWord32 /*notificationMs*/){}
|
||||
virtual void RecordNotification(const WebRtc_Word32 id,
|
||||
const WebRtc_UWord32 notificationMs){}
|
||||
virtual void PlayFileEnded(const WebRtc_Word32 id);
|
||||
virtual void RecordFileEnded(const WebRtc_Word32 id) { }
|
||||
// Implements webrtc::InStream.
|
||||
virtual int Read(void* buf, int len);
|
||||
virtual int Rewind() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Implements FileCallback.
|
||||
virtual void PlayNotification(const WebRtc_Word32 /*id*/,
|
||||
const WebRtc_UWord32 /*notification_ms*/) {}
|
||||
virtual void RecordNotification(const WebRtc_Word32 /*id*/,
|
||||
const WebRtc_UWord32 /*notification_ms*/) {}
|
||||
virtual void PlayFileEnded(const WebRtc_Word32 id);
|
||||
virtual void RecordFileEnded(const WebRtc_Word32 /*id*/) {}
|
||||
|
||||
private:
|
||||
enum { kThreadWaitTimeMs = 100 };
|
||||
private:
|
||||
bool play_back_started_;
|
||||
ViEInputManager& input_manager_;
|
||||
|
||||
bool _playBackStarted;
|
||||
ViEInputManager& _inputManager;
|
||||
CriticalSectionWrapper* feedback_cs_;
|
||||
CriticalSectionWrapper* audio_cs_;
|
||||
|
||||
CriticalSectionWrapper* _ptrFeedBackCritSect;
|
||||
CriticalSectionWrapper* _ptrAudioCritSect;
|
||||
FilePlayer* file_player_;
|
||||
bool audio_stream_;
|
||||
|
||||
webrtc::FilePlayer* _filePlayer;
|
||||
bool _audioStream;
|
||||
// Number of active video clients.
|
||||
int video_clients_;
|
||||
|
||||
int _videoClients; // Number of active video clients
|
||||
int _audioClients; //No of audio channels sending this audio.
|
||||
int _localAudioChannel; //Local audio channel playing this video. Sync video against this.
|
||||
// Number of audio channels sending this audio.
|
||||
int audio_clients_;
|
||||
|
||||
ViEFileObserver* _observer;
|
||||
WebRtc_Word8 _fileName[FileWrapper::kMaxFileNameSize];
|
||||
// Local audio channel playing this video. Sync video against this.
|
||||
int local_audio_channel_;
|
||||
|
||||
// VE Interface
|
||||
VoEFile* _veFileInterface;
|
||||
VoEVideoSync* _veVideoSync;
|
||||
// Thread for decoding video (and audio if no audio clients connected)
|
||||
ThreadWrapper* _ptrDecodeThread;
|
||||
EventWrapper* _ptrDecodeEvent;
|
||||
WebRtc_Word16 _decodedAudio[320];
|
||||
WebRtc_UWord32 _decodedAudioLength;
|
||||
ViEFileObserver* observer_;
|
||||
WebRtc_Word8 file_name_[FileWrapper::kMaxFileNameSize];
|
||||
|
||||
ListWrapper _audioChannelBuffers; //trick - list containing VE buffer reading this file. Used if multiple audio channels are sending.
|
||||
MapWrapper _audioChannelsSending; // AudioChannels sending audio from this file
|
||||
VideoFrame _decodedVideo; // Frame receiving decoded video from file.
|
||||
// VoE Interface.
|
||||
VoEFile* voe_file_interface_;
|
||||
VoEVideoSync* voe_video_sync_;
|
||||
|
||||
// Thread for decoding video (and audio if no audio clients connected).
|
||||
ThreadWrapper* decode_thread_;
|
||||
EventWrapper* decode_event_;
|
||||
WebRtc_Word16 decoded_audio_[320];
|
||||
WebRtc_UWord32 decoded_audio_length_;
|
||||
|
||||
// Trick - list containing VoE buffer reading this file. Used if multiple
|
||||
// audio channels are sending.
|
||||
ListWrapper audio_channel_buffers_;
|
||||
|
||||
// AudioChannels sending audio from this file.
|
||||
MapWrapper audio_channels_sending_;
|
||||
|
||||
// Frame receiving decoded video from file.
|
||||
VideoFrame decoded_video_;
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_FILE_PLAYER_H_
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_VIDEO_ENGINE_VIE_FILE_PLAYER_H_
|
||||
|
Loading…
x
Reference in New Issue
Block a user