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.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
#ifndef WEBRTC_VIDEO_ENGINE_VIE_FILE_PLAYER_H_
|
||||||
* vie_file_player.h
|
#define WEBRTC_VIDEO_ENGINE_VIE_FILE_PLAYER_H_
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_FILE_PLAYER_H_
|
|
||||||
#define WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_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 "typedefs.h"
|
||||||
#include "common_types.h" // webrtc::OutStream
|
#include "video_engine/vie_frame_provider_base.h"
|
||||||
#include "file_player.h"
|
|
||||||
#include "media_file_defines.h"
|
namespace webrtc {
|
||||||
#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"
|
|
||||||
|
|
||||||
namespace webrtc
|
|
||||||
{
|
|
||||||
class EventWrapper;
|
class EventWrapper;
|
||||||
|
class FilePlayer;
|
||||||
class ThreadWrapper;
|
class ThreadWrapper;
|
||||||
|
class ViEFileObserver;
|
||||||
class ViEInputManager;
|
class ViEInputManager;
|
||||||
class ViEFilePlayer: public ViEFrameProviderBase,
|
class VoEFile;
|
||||||
protected webrtc::FileCallback,
|
class VoEVideoSync;
|
||||||
protected webrtc::InStream // for audio
|
class VoiceEngine;
|
||||||
{
|
|
||||||
public:
|
|
||||||
static ViEFilePlayer *CreateViEFilePlayer(int fileId, int engineId,
|
|
||||||
const char* fileNameUTF8,
|
|
||||||
const bool loop,
|
|
||||||
const webrtc::FileFormats fileFormat,
|
|
||||||
ViEInputManager& inputManager,
|
|
||||||
VoiceEngine* vePtr);
|
|
||||||
|
|
||||||
static int GetFileInformation(const int engineId,
|
class ViEFilePlayer
|
||||||
const char* fileName,
|
: public ViEFrameProviderBase,
|
||||||
webrtc::VideoCodec& videoCodec,
|
protected FileCallback,
|
||||||
webrtc::CodecInst& audioCodec,
|
protected InStream {
|
||||||
const webrtc::FileFormats fileFormat);
|
public:
|
||||||
~ViEFilePlayer();
|
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();
|
static int GetFileInformation(const int engine_id,
|
||||||
int RegisterObserver(ViEFileObserver& observer);
|
const char* file_name,
|
||||||
int DeRegisterObserver();
|
VideoCodec& video_codec,
|
||||||
int SendAudioOnChannel(const int audioChannel, bool mixMicrophone,
|
CodecInst& audio_codec,
|
||||||
float volumeScaling);
|
const FileFormats file_format);
|
||||||
int StopSendAudioOnChannel(const int audioChannel);
|
~ViEFilePlayer();
|
||||||
int PlayAudioLocally(const int audioChannel, float volumeScaling);
|
|
||||||
int StopPlayAudioLocally(const int audioChannel);
|
|
||||||
|
|
||||||
//Implement ViEFrameProviderBase
|
bool IsObserverRegistered();
|
||||||
virtual int FrameCallbackChanged();
|
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:
|
// Implements ViEFrameProviderBase.
|
||||||
ViEFilePlayer(int Id, int engineId, ViEInputManager& inputManager);
|
virtual int FrameCallbackChanged();
|
||||||
int Init(const WebRtc_Word8* fileNameUTF8, const bool loop,
|
|
||||||
const webrtc::FileFormats fileFormat, VoiceEngine* vePtr);
|
|
||||||
int StopPlay();
|
|
||||||
int StopPlayAudio();
|
|
||||||
|
|
||||||
// File play decode function.
|
protected:
|
||||||
static bool FilePlayDecodeThreadFunction(void* obj);
|
ViEFilePlayer(int Id, int engine_id, ViEInputManager& input_manager);
|
||||||
bool FilePlayDecodeProcess();
|
int Init(const WebRtc_Word8* file_nameUTF8,
|
||||||
bool NeedsAudioFromFile(void* buf);
|
const bool loop,
|
||||||
|
const FileFormats file_format,
|
||||||
|
VoiceEngine* voe_ptr);
|
||||||
|
int StopPlay();
|
||||||
|
int StopPlayAudio();
|
||||||
|
|
||||||
// From webrtc::InStream
|
// File play decode function.
|
||||||
virtual int Read(void *buf, int len);
|
static bool FilePlayDecodeThreadFunction(void* obj);
|
||||||
virtual int Rewind() { return 0;}
|
bool FilePlayDecodeProcess();
|
||||||
|
bool NeedsAudioFromFile(void* buf);
|
||||||
|
|
||||||
// From FileCallback
|
// Implements webrtc::InStream.
|
||||||
virtual void PlayNotification(const WebRtc_Word32 /*id*/,
|
virtual int Read(void* buf, int len);
|
||||||
const WebRtc_UWord32 /*notificationMs*/){}
|
virtual int Rewind() {
|
||||||
virtual void RecordNotification(const WebRtc_Word32 id,
|
return 0;
|
||||||
const WebRtc_UWord32 notificationMs){}
|
}
|
||||||
virtual void PlayFileEnded(const WebRtc_Word32 id);
|
|
||||||
virtual void RecordFileEnded(const WebRtc_Word32 id) { }
|
|
||||||
|
|
||||||
|
// 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:
|
private:
|
||||||
enum { kThreadWaitTimeMs = 100 };
|
bool play_back_started_;
|
||||||
|
ViEInputManager& input_manager_;
|
||||||
|
|
||||||
bool _playBackStarted;
|
CriticalSectionWrapper* feedback_cs_;
|
||||||
ViEInputManager& _inputManager;
|
CriticalSectionWrapper* audio_cs_;
|
||||||
|
|
||||||
CriticalSectionWrapper* _ptrFeedBackCritSect;
|
FilePlayer* file_player_;
|
||||||
CriticalSectionWrapper* _ptrAudioCritSect;
|
bool audio_stream_;
|
||||||
|
|
||||||
webrtc::FilePlayer* _filePlayer;
|
// Number of active video clients.
|
||||||
bool _audioStream;
|
int video_clients_;
|
||||||
|
|
||||||
int _videoClients; // Number of active video clients
|
// Number of audio channels sending this audio.
|
||||||
int _audioClients; //No of audio channels sending this audio.
|
int audio_clients_;
|
||||||
int _localAudioChannel; //Local audio channel playing this video. Sync video against this.
|
|
||||||
|
|
||||||
ViEFileObserver* _observer;
|
// Local audio channel playing this video. Sync video against this.
|
||||||
WebRtc_Word8 _fileName[FileWrapper::kMaxFileNameSize];
|
int local_audio_channel_;
|
||||||
|
|
||||||
// VE Interface
|
ViEFileObserver* observer_;
|
||||||
VoEFile* _veFileInterface;
|
WebRtc_Word8 file_name_[FileWrapper::kMaxFileNameSize];
|
||||||
VoEVideoSync* _veVideoSync;
|
|
||||||
// Thread for decoding video (and audio if no audio clients connected)
|
|
||||||
ThreadWrapper* _ptrDecodeThread;
|
|
||||||
EventWrapper* _ptrDecodeEvent;
|
|
||||||
WebRtc_Word16 _decodedAudio[320];
|
|
||||||
WebRtc_UWord32 _decodedAudioLength;
|
|
||||||
|
|
||||||
ListWrapper _audioChannelBuffers; //trick - list containing VE buffer reading this file. Used if multiple audio channels are sending.
|
// VoE Interface.
|
||||||
MapWrapper _audioChannelsSending; // AudioChannels sending audio from this file
|
VoEFile* voe_file_interface_;
|
||||||
VideoFrame _decodedVideo; // Frame receiving decoded video from file.
|
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