WebRtc_Word32 -> int32_t in utility/
BUG=314 Review URL: https://webrtc-codereview.appspot.com/1307005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3797 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
0ea11c1768
commit
c75102eba7
@ -29,7 +29,7 @@ public:
|
|||||||
|
|
||||||
// Note: will return NULL for video file formats (e.g. AVI) if the flag
|
// Note: will return NULL for video file formats (e.g. AVI) if the flag
|
||||||
// WEBRTC_MODULE_UTILITY_VIDEO is not defined.
|
// WEBRTC_MODULE_UTILITY_VIDEO is not defined.
|
||||||
static FilePlayer* CreateFilePlayer(const WebRtc_UWord32 instanceID,
|
static FilePlayer* CreateFilePlayer(const uint32_t instanceID,
|
||||||
const FileFormats fileFormat);
|
const FileFormats fileFormat);
|
||||||
|
|
||||||
static void DestroyFilePlayer(FilePlayer* player);
|
static void DestroyFilePlayer(FilePlayer* player);
|
||||||
@ -43,65 +43,65 @@ public:
|
|||||||
int frequencyInHz) = 0;
|
int frequencyInHz) = 0;
|
||||||
|
|
||||||
// Register callback for receiving file playing notifications.
|
// Register callback for receiving file playing notifications.
|
||||||
virtual WebRtc_Word32 RegisterModuleFileCallback(
|
virtual int32_t RegisterModuleFileCallback(
|
||||||
FileCallback* callback) = 0;
|
FileCallback* callback) = 0;
|
||||||
|
|
||||||
// API for playing audio from fileName to channel.
|
// API for playing audio from fileName to channel.
|
||||||
// Note: codecInst is used for pre-encoded files.
|
// Note: codecInst is used for pre-encoded files.
|
||||||
virtual WebRtc_Word32 StartPlayingFile(
|
virtual int32_t StartPlayingFile(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
bool loop,
|
bool loop,
|
||||||
WebRtc_UWord32 startPosition,
|
uint32_t startPosition,
|
||||||
float volumeScaling,
|
float volumeScaling,
|
||||||
WebRtc_UWord32 notification,
|
uint32_t notification,
|
||||||
WebRtc_UWord32 stopPosition = 0,
|
uint32_t stopPosition = 0,
|
||||||
const CodecInst* codecInst = NULL) = 0;
|
const CodecInst* codecInst = NULL) = 0;
|
||||||
|
|
||||||
// Note: codecInst is used for pre-encoded files.
|
// Note: codecInst is used for pre-encoded files.
|
||||||
virtual WebRtc_Word32 StartPlayingFile(
|
virtual int32_t StartPlayingFile(
|
||||||
InStream& sourceStream,
|
InStream& sourceStream,
|
||||||
WebRtc_UWord32 startPosition,
|
uint32_t startPosition,
|
||||||
float volumeScaling,
|
float volumeScaling,
|
||||||
WebRtc_UWord32 notification,
|
uint32_t notification,
|
||||||
WebRtc_UWord32 stopPosition = 0,
|
uint32_t stopPosition = 0,
|
||||||
const CodecInst* codecInst = NULL) = 0;
|
const CodecInst* codecInst = NULL) = 0;
|
||||||
|
|
||||||
virtual WebRtc_Word32 StopPlayingFile() = 0;
|
virtual int32_t StopPlayingFile() = 0;
|
||||||
|
|
||||||
virtual bool IsPlayingFile() const = 0;
|
virtual bool IsPlayingFile() const = 0;
|
||||||
|
|
||||||
virtual WebRtc_Word32 GetPlayoutPosition(WebRtc_UWord32& durationMs) = 0;
|
virtual int32_t GetPlayoutPosition(uint32_t& durationMs) = 0;
|
||||||
|
|
||||||
// Set audioCodec to the currently used audio codec.
|
// Set audioCodec to the currently used audio codec.
|
||||||
virtual WebRtc_Word32 AudioCodec(CodecInst& audioCodec) const = 0;
|
virtual int32_t AudioCodec(CodecInst& audioCodec) const = 0;
|
||||||
|
|
||||||
virtual WebRtc_Word32 Frequency() const = 0;
|
virtual int32_t Frequency() const = 0;
|
||||||
|
|
||||||
// Note: scaleFactor is in the range [0.0 - 2.0]
|
// Note: scaleFactor is in the range [0.0 - 2.0]
|
||||||
virtual WebRtc_Word32 SetAudioScaling(float scaleFactor) = 0;
|
virtual int32_t SetAudioScaling(float scaleFactor) = 0;
|
||||||
|
|
||||||
// Return the time in ms until next video frame should be pulled (by
|
// Return the time in ms until next video frame should be pulled (by
|
||||||
// calling GetVideoFromFile(..)).
|
// calling GetVideoFromFile(..)).
|
||||||
// Note: this API reads one video frame from file. This means that it should
|
// Note: this API reads one video frame from file. This means that it should
|
||||||
// be called exactly once per GetVideoFromFile(..) API call.
|
// be called exactly once per GetVideoFromFile(..) API call.
|
||||||
virtual WebRtc_Word32 TimeUntilNextVideoFrame() { return -1;}
|
virtual int32_t TimeUntilNextVideoFrame() { return -1;}
|
||||||
|
|
||||||
virtual WebRtc_Word32 StartPlayingVideoFile(
|
virtual int32_t StartPlayingVideoFile(
|
||||||
const char* /*fileName*/,
|
const char* /*fileName*/,
|
||||||
bool /*loop*/,
|
bool /*loop*/,
|
||||||
bool /*videoOnly*/) { return -1;}
|
bool /*videoOnly*/) { return -1;}
|
||||||
|
|
||||||
virtual WebRtc_Word32 video_codec_info(VideoCodec& /*videoCodec*/) const
|
virtual int32_t video_codec_info(VideoCodec& /*videoCodec*/) const
|
||||||
{return -1;}
|
{return -1;}
|
||||||
|
|
||||||
virtual WebRtc_Word32 GetVideoFromFile(I420VideoFrame& /*videoFrame*/)
|
virtual int32_t GetVideoFromFile(I420VideoFrame& /*videoFrame*/)
|
||||||
{ return -1;}
|
{ return -1;}
|
||||||
|
|
||||||
// Same as GetVideoFromFile(). videoFrame will have the resolution specified
|
// Same as GetVideoFromFile(). videoFrame will have the resolution specified
|
||||||
// by the width outWidth and height outHeight in pixels.
|
// by the width outWidth and height outHeight in pixels.
|
||||||
virtual WebRtc_Word32 GetVideoFromFile(I420VideoFrame& /*videoFrame*/,
|
virtual int32_t GetVideoFromFile(I420VideoFrame& /*videoFrame*/,
|
||||||
const WebRtc_UWord32 /*outWidth*/,
|
const uint32_t /*outWidth*/,
|
||||||
const WebRtc_UWord32 /*outHeight*/)
|
const uint32_t /*outHeight*/)
|
||||||
{return -1;}
|
{return -1;}
|
||||||
protected:
|
protected:
|
||||||
virtual ~FilePlayer() {}
|
virtual ~FilePlayer() {}
|
||||||
|
@ -28,40 +28,40 @@ public:
|
|||||||
|
|
||||||
// Note: will return NULL for video file formats (e.g. AVI) if the flag
|
// Note: will return NULL for video file formats (e.g. AVI) if the flag
|
||||||
// WEBRTC_MODULE_UTILITY_VIDEO is not defined.
|
// WEBRTC_MODULE_UTILITY_VIDEO is not defined.
|
||||||
static FileRecorder* CreateFileRecorder(const WebRtc_UWord32 instanceID,
|
static FileRecorder* CreateFileRecorder(const uint32_t instanceID,
|
||||||
const FileFormats fileFormat);
|
const FileFormats fileFormat);
|
||||||
|
|
||||||
static void DestroyFileRecorder(FileRecorder* recorder);
|
static void DestroyFileRecorder(FileRecorder* recorder);
|
||||||
|
|
||||||
virtual WebRtc_Word32 RegisterModuleFileCallback(
|
virtual int32_t RegisterModuleFileCallback(
|
||||||
FileCallback* callback) = 0;
|
FileCallback* callback) = 0;
|
||||||
|
|
||||||
virtual FileFormats RecordingFileFormat() const = 0;
|
virtual FileFormats RecordingFileFormat() const = 0;
|
||||||
|
|
||||||
virtual WebRtc_Word32 StartRecordingAudioFile(
|
virtual int32_t StartRecordingAudioFile(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
const CodecInst& codecInst,
|
const CodecInst& codecInst,
|
||||||
WebRtc_UWord32 notification,
|
uint32_t notification,
|
||||||
ACMAMRPackingFormat amrFormat = AMRFileStorage) = 0;
|
ACMAMRPackingFormat amrFormat = AMRFileStorage) = 0;
|
||||||
|
|
||||||
virtual WebRtc_Word32 StartRecordingAudioFile(
|
virtual int32_t StartRecordingAudioFile(
|
||||||
OutStream& destStream,
|
OutStream& destStream,
|
||||||
const CodecInst& codecInst,
|
const CodecInst& codecInst,
|
||||||
WebRtc_UWord32 notification,
|
uint32_t notification,
|
||||||
ACMAMRPackingFormat amrFormat = AMRFileStorage) = 0;
|
ACMAMRPackingFormat amrFormat = AMRFileStorage) = 0;
|
||||||
|
|
||||||
// Stop recording.
|
// Stop recording.
|
||||||
// Note: this API is for both audio and video.
|
// Note: this API is for both audio and video.
|
||||||
virtual WebRtc_Word32 StopRecording() = 0;
|
virtual int32_t StopRecording() = 0;
|
||||||
|
|
||||||
// Return true if recording.
|
// Return true if recording.
|
||||||
// Note: this API is for both audio and video.
|
// Note: this API is for both audio and video.
|
||||||
virtual bool IsRecording() const = 0;
|
virtual bool IsRecording() const = 0;
|
||||||
|
|
||||||
virtual WebRtc_Word32 codec_info(CodecInst& codecInst) const = 0;
|
virtual int32_t codec_info(CodecInst& codecInst) const = 0;
|
||||||
|
|
||||||
// Write frame to file. Frame should contain 10ms of un-ecoded audio data.
|
// Write frame to file. Frame should contain 10ms of un-ecoded audio data.
|
||||||
virtual WebRtc_Word32 RecordAudioToFile(
|
virtual int32_t RecordAudioToFile(
|
||||||
const AudioFrame& frame,
|
const AudioFrame& frame,
|
||||||
const TickTime* playoutTS = NULL) = 0;
|
const TickTime* playoutTS = NULL) = 0;
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ public:
|
|||||||
// Only video data will be recorded if videoOnly is true. amrFormat
|
// Only video data will be recorded if videoOnly is true. amrFormat
|
||||||
// specifies the amr/amrwb storage format.
|
// specifies the amr/amrwb storage format.
|
||||||
// Note: the file format is AVI.
|
// Note: the file format is AVI.
|
||||||
virtual WebRtc_Word32 StartRecordingVideoFile(
|
virtual int32_t StartRecordingVideoFile(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
const CodecInst& audioCodecInst,
|
const CodecInst& audioCodecInst,
|
||||||
const VideoCodec& videoCodecInst,
|
const VideoCodec& videoCodecInst,
|
||||||
@ -79,7 +79,7 @@ public:
|
|||||||
bool videoOnly = false) = 0;
|
bool videoOnly = false) = 0;
|
||||||
|
|
||||||
// Record the video frame in videoFrame to AVI file.
|
// Record the video frame in videoFrame to AVI file.
|
||||||
virtual WebRtc_Word32 RecordVideoToFile(
|
virtual int32_t RecordVideoToFile(
|
||||||
const I420VideoFrame& videoFrame) = 0;
|
const I420VideoFrame& videoFrame) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -22,11 +22,11 @@ public:
|
|||||||
static ProcessThread* CreateProcessThread();
|
static ProcessThread* CreateProcessThread();
|
||||||
static void DestroyProcessThread(ProcessThread* module);
|
static void DestroyProcessThread(ProcessThread* module);
|
||||||
|
|
||||||
virtual WebRtc_Word32 Start() = 0;
|
virtual int32_t Start() = 0;
|
||||||
virtual WebRtc_Word32 Stop() = 0;
|
virtual int32_t Stop() = 0;
|
||||||
|
|
||||||
virtual WebRtc_Word32 RegisterModule(const Module* module) = 0;
|
virtual int32_t RegisterModule(const Module* module) = 0;
|
||||||
virtual WebRtc_Word32 DeRegisterModule(const Module* module) = 0;
|
virtual int32_t DeRegisterModule(const Module* module) = 0;
|
||||||
protected:
|
protected:
|
||||||
virtual ~ProcessThread();
|
virtual ~ProcessThread();
|
||||||
};
|
};
|
||||||
|
@ -31,10 +31,10 @@ public:
|
|||||||
|
|
||||||
// Open the file fileNameUTF8 for writing RTP/RTCP packets.
|
// Open the file fileNameUTF8 for writing RTP/RTCP packets.
|
||||||
// Note: this API also adds the rtpplay header.
|
// Note: this API also adds the rtpplay header.
|
||||||
virtual WebRtc_Word32 Start(const char* fileNameUTF8) = 0;
|
virtual int32_t Start(const char* fileNameUTF8) = 0;
|
||||||
|
|
||||||
// Close the existing file. No more packets will be recorded.
|
// Close the existing file. No more packets will be recorded.
|
||||||
virtual WebRtc_Word32 Stop() = 0;
|
virtual int32_t Stop() = 0;
|
||||||
|
|
||||||
// Return true if a file is open for recording RTP/RTCP packets.
|
// Return true if a file is open for recording RTP/RTCP packets.
|
||||||
virtual bool IsActive() const = 0;
|
virtual bool IsActive() const = 0;
|
||||||
@ -42,8 +42,8 @@ public:
|
|||||||
// Writes the RTP/RTCP packet in packet with length packetLength in bytes.
|
// Writes the RTP/RTCP packet in packet with length packetLength in bytes.
|
||||||
// Note: packet should contain the RTP/RTCP part of the packet. I.e. the
|
// Note: packet should contain the RTP/RTCP part of the packet. I.e. the
|
||||||
// first bytes of packet should be the RTP/RTCP header.
|
// first bytes of packet should be the RTP/RTCP header.
|
||||||
virtual WebRtc_Word32 DumpPacket(const WebRtc_UWord8* packet,
|
virtual int32_t DumpPacket(const uint8_t* packet,
|
||||||
WebRtc_UWord16 packetLength) = 0;
|
uint16_t packetLength) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~RtpDump();
|
virtual ~RtpDump();
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
AudioCoder::AudioCoder(WebRtc_UWord32 instanceID)
|
AudioCoder::AudioCoder(uint32_t instanceID)
|
||||||
: _acm(AudioCodingModule::Create(instanceID)),
|
: _acm(AudioCodingModule::Create(instanceID)),
|
||||||
_receiveCodec(),
|
_receiveCodec(),
|
||||||
_encodeTimestamp(0),
|
_encodeTimestamp(0),
|
||||||
@ -38,7 +38,7 @@ AudioCoder::~AudioCoder()
|
|||||||
AudioCodingModule::Destroy(_acm);
|
AudioCodingModule::Destroy(_acm);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AudioCoder::SetEncodeCodec(const CodecInst& codecInst,
|
int32_t AudioCoder::SetEncodeCodec(const CodecInst& codecInst,
|
||||||
ACMAMRPackingFormat amrFormat)
|
ACMAMRPackingFormat amrFormat)
|
||||||
{
|
{
|
||||||
if(_acm->RegisterSendCodec((CodecInst&)codecInst) == -1)
|
if(_acm->RegisterSendCodec((CodecInst&)codecInst) == -1)
|
||||||
@ -48,7 +48,7 @@ WebRtc_Word32 AudioCoder::SetEncodeCodec(const CodecInst& codecInst,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AudioCoder::SetDecodeCodec(const CodecInst& codecInst,
|
int32_t AudioCoder::SetDecodeCodec(const CodecInst& codecInst,
|
||||||
ACMAMRPackingFormat amrFormat)
|
ACMAMRPackingFormat amrFormat)
|
||||||
{
|
{
|
||||||
if(_acm->RegisterReceiveCodec((CodecInst&)codecInst) == -1)
|
if(_acm->RegisterReceiveCodec((CodecInst&)codecInst) == -1)
|
||||||
@ -59,16 +59,16 @@ WebRtc_Word32 AudioCoder::SetDecodeCodec(const CodecInst& codecInst,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AudioCoder::Decode(AudioFrame& decodedAudio,
|
int32_t AudioCoder::Decode(AudioFrame& decodedAudio,
|
||||||
WebRtc_UWord32 sampFreqHz,
|
uint32_t sampFreqHz,
|
||||||
const WebRtc_Word8* incomingPayload,
|
const int8_t* incomingPayload,
|
||||||
WebRtc_Word32 payloadLength)
|
int32_t payloadLength)
|
||||||
{
|
{
|
||||||
if (payloadLength > 0)
|
if (payloadLength > 0)
|
||||||
{
|
{
|
||||||
const WebRtc_UWord8 payloadType = _receiveCodec.pltype;
|
const uint8_t payloadType = _receiveCodec.pltype;
|
||||||
_decodeTimestamp += _receiveCodec.pacsize;
|
_decodeTimestamp += _receiveCodec.pacsize;
|
||||||
if(_acm->IncomingPayload((const WebRtc_UWord8*) incomingPayload,
|
if(_acm->IncomingPayload((const uint8_t*) incomingPayload,
|
||||||
payloadLength,
|
payloadLength,
|
||||||
payloadType,
|
payloadType,
|
||||||
_decodeTimestamp) == -1)
|
_decodeTimestamp) == -1)
|
||||||
@ -76,18 +76,18 @@ WebRtc_Word32 AudioCoder::Decode(AudioFrame& decodedAudio,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _acm->PlayoutData10Ms((WebRtc_UWord16)sampFreqHz, &decodedAudio);
|
return _acm->PlayoutData10Ms((uint16_t)sampFreqHz, &decodedAudio);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AudioCoder::PlayoutData(AudioFrame& decodedAudio,
|
int32_t AudioCoder::PlayoutData(AudioFrame& decodedAudio,
|
||||||
WebRtc_UWord16& sampFreqHz)
|
uint16_t& sampFreqHz)
|
||||||
{
|
{
|
||||||
return _acm->PlayoutData10Ms(sampFreqHz, &decodedAudio);
|
return _acm->PlayoutData10Ms(sampFreqHz, &decodedAudio);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AudioCoder::Encode(const AudioFrame& audio,
|
int32_t AudioCoder::Encode(const AudioFrame& audio,
|
||||||
WebRtc_Word8* encodedData,
|
int8_t* encodedData,
|
||||||
WebRtc_UWord32& encodedLengthInBytes)
|
uint32_t& encodedLengthInBytes)
|
||||||
{
|
{
|
||||||
// Fake a timestamp in case audio doesn't contain a correct timestamp.
|
// Fake a timestamp in case audio doesn't contain a correct timestamp.
|
||||||
// Make a local copy of the audio frame since audio is const
|
// Make a local copy of the audio frame since audio is const
|
||||||
@ -112,15 +112,15 @@ WebRtc_Word32 AudioCoder::Encode(const AudioFrame& audio,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AudioCoder::SendData(
|
int32_t AudioCoder::SendData(
|
||||||
FrameType /* frameType */,
|
FrameType /* frameType */,
|
||||||
WebRtc_UWord8 /* payloadType */,
|
uint8_t /* payloadType */,
|
||||||
WebRtc_UWord32 /* timeStamp */,
|
uint32_t /* timeStamp */,
|
||||||
const WebRtc_UWord8* payloadData,
|
const uint8_t* payloadData,
|
||||||
WebRtc_UWord16 payloadSize,
|
uint16_t payloadSize,
|
||||||
const RTPFragmentationHeader* /* fragmentation*/)
|
const RTPFragmentationHeader* /* fragmentation*/)
|
||||||
{
|
{
|
||||||
memcpy(_encodedData,payloadData,sizeof(WebRtc_UWord8) * payloadSize);
|
memcpy(_encodedData,payloadData,sizeof(uint8_t) * payloadSize);
|
||||||
_encodedLengthInBytes = payloadSize;
|
_encodedLengthInBytes = payloadSize;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -21,34 +21,31 @@ class AudioFrame;
|
|||||||
class AudioCoder : public AudioPacketizationCallback
|
class AudioCoder : public AudioPacketizationCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioCoder(WebRtc_UWord32 instanceID);
|
AudioCoder(uint32_t instanceID);
|
||||||
~AudioCoder();
|
~AudioCoder();
|
||||||
|
|
||||||
WebRtc_Word32 SetEncodeCodec(
|
int32_t SetEncodeCodec(
|
||||||
const CodecInst& codecInst,
|
const CodecInst& codecInst,
|
||||||
ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
|
ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
|
||||||
|
|
||||||
WebRtc_Word32 SetDecodeCodec(
|
int32_t SetDecodeCodec(
|
||||||
const CodecInst& codecInst,
|
const CodecInst& codecInst,
|
||||||
ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
|
ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
|
||||||
|
|
||||||
WebRtc_Word32 Decode(AudioFrame& decodedAudio, WebRtc_UWord32 sampFreqHz,
|
int32_t Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz,
|
||||||
const WebRtc_Word8* incomingPayload,
|
const int8_t* incomingPayload, int32_t payloadLength);
|
||||||
WebRtc_Word32 payloadLength);
|
|
||||||
|
|
||||||
WebRtc_Word32 PlayoutData(AudioFrame& decodedAudio,
|
int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz);
|
||||||
WebRtc_UWord16& sampFreqHz);
|
|
||||||
|
|
||||||
WebRtc_Word32 Encode(const AudioFrame& audio,
|
int32_t Encode(const AudioFrame& audio, int8_t* encodedData,
|
||||||
WebRtc_Word8* encodedData,
|
uint32_t& encodedLengthInBytes);
|
||||||
WebRtc_UWord32& encodedLengthInBytes);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual WebRtc_Word32 SendData(FrameType frameType,
|
virtual int32_t SendData(FrameType frameType,
|
||||||
WebRtc_UWord8 payloadType,
|
uint8_t payloadType,
|
||||||
WebRtc_UWord32 timeStamp,
|
uint32_t timeStamp,
|
||||||
const WebRtc_UWord8* payloadData,
|
const uint8_t* payloadData,
|
||||||
WebRtc_UWord16 payloadSize,
|
uint16_t payloadSize,
|
||||||
const RTPFragmentationHeader* fragmentation);
|
const RTPFragmentationHeader* fragmentation);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -56,11 +53,11 @@ private:
|
|||||||
|
|
||||||
CodecInst _receiveCodec;
|
CodecInst _receiveCodec;
|
||||||
|
|
||||||
WebRtc_UWord32 _encodeTimestamp;
|
uint32_t _encodeTimestamp;
|
||||||
WebRtc_Word8* _encodedData;
|
int8_t* _encodedData;
|
||||||
WebRtc_UWord32 _encodedLengthInBytes;
|
uint32_t _encodedLengthInBytes;
|
||||||
|
|
||||||
WebRtc_UWord32 _decodeTimestamp;
|
uint32_t _decodeTimestamp;
|
||||||
};
|
};
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
FilePlayer* FilePlayer::CreateFilePlayer(WebRtc_UWord32 instanceID,
|
FilePlayer* FilePlayer::CreateFilePlayer(uint32_t instanceID,
|
||||||
FileFormats fileFormat)
|
FileFormats fileFormat)
|
||||||
{
|
{
|
||||||
switch(fileFormat)
|
switch(fileFormat)
|
||||||
@ -57,7 +57,7 @@ void FilePlayer::DestroyFilePlayer(FilePlayer* player)
|
|||||||
delete player;
|
delete player;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePlayerImpl::FilePlayerImpl(const WebRtc_UWord32 instanceID,
|
FilePlayerImpl::FilePlayerImpl(const uint32_t instanceID,
|
||||||
const FileFormats fileFormat)
|
const FileFormats fileFormat)
|
||||||
: _instanceID(instanceID),
|
: _instanceID(instanceID),
|
||||||
_fileFormat(fileFormat),
|
_fileFormat(fileFormat),
|
||||||
@ -78,7 +78,7 @@ FilePlayerImpl::~FilePlayerImpl()
|
|||||||
MediaFile::DestroyMediaFile(&_fileModule);
|
MediaFile::DestroyMediaFile(&_fileModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FilePlayerImpl::Frequency() const
|
int32_t FilePlayerImpl::Frequency() const
|
||||||
{
|
{
|
||||||
if(_codec.plfreq == 0)
|
if(_codec.plfreq == 0)
|
||||||
{
|
{
|
||||||
@ -108,13 +108,13 @@ WebRtc_Word32 FilePlayerImpl::Frequency() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FilePlayerImpl::AudioCodec(CodecInst& audioCodec) const
|
int32_t FilePlayerImpl::AudioCodec(CodecInst& audioCodec) const
|
||||||
{
|
{
|
||||||
audioCodec = _codec;
|
audioCodec = _codec;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
int32_t FilePlayerImpl::Get10msAudioFromFile(
|
||||||
int16_t* outBuffer,
|
int16_t* outBuffer,
|
||||||
int& lengthInSamples,
|
int& lengthInSamples,
|
||||||
int frequencyInHz)
|
int frequencyInHz)
|
||||||
@ -134,10 +134,10 @@ WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
|||||||
unresampledAudioFrame.sample_rate_hz_ = _codec.plfreq;
|
unresampledAudioFrame.sample_rate_hz_ = _codec.plfreq;
|
||||||
|
|
||||||
// L16 is un-encoded data. Just pull 10 ms.
|
// L16 is un-encoded data. Just pull 10 ms.
|
||||||
WebRtc_UWord32 lengthInBytes =
|
uint32_t lengthInBytes =
|
||||||
sizeof(unresampledAudioFrame.data_);
|
sizeof(unresampledAudioFrame.data_);
|
||||||
if (_fileModule.PlayoutAudioData(
|
if (_fileModule.PlayoutAudioData(
|
||||||
(WebRtc_Word8*)unresampledAudioFrame.data_,
|
(int8_t*)unresampledAudioFrame.data_,
|
||||||
lengthInBytes) == -1)
|
lengthInBytes) == -1)
|
||||||
{
|
{
|
||||||
// End of file reached.
|
// End of file reached.
|
||||||
@ -150,19 +150,19 @@ WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
|||||||
}
|
}
|
||||||
// One sample is two bytes.
|
// One sample is two bytes.
|
||||||
unresampledAudioFrame.samples_per_channel_ =
|
unresampledAudioFrame.samples_per_channel_ =
|
||||||
(WebRtc_UWord16)lengthInBytes >> 1;
|
(uint16_t)lengthInBytes >> 1;
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
// Decode will generate 10 ms of audio data. PlayoutAudioData(..)
|
// Decode will generate 10 ms of audio data. PlayoutAudioData(..)
|
||||||
// expects a full frame. If the frame size is larger than 10 ms,
|
// expects a full frame. If the frame size is larger than 10 ms,
|
||||||
// PlayoutAudioData(..) data should be called proportionally less often.
|
// PlayoutAudioData(..) data should be called proportionally less often.
|
||||||
WebRtc_Word16 encodedBuffer[MAX_AUDIO_BUFFER_IN_SAMPLES];
|
int16_t encodedBuffer[MAX_AUDIO_BUFFER_IN_SAMPLES];
|
||||||
WebRtc_UWord32 encodedLengthInBytes = 0;
|
uint32_t encodedLengthInBytes = 0;
|
||||||
if(++_numberOf10MsInDecoder >= _numberOf10MsPerFrame)
|
if(++_numberOf10MsInDecoder >= _numberOf10MsPerFrame)
|
||||||
{
|
{
|
||||||
_numberOf10MsInDecoder = 0;
|
_numberOf10MsInDecoder = 0;
|
||||||
WebRtc_UWord32 bytesFromFile = sizeof(encodedBuffer);
|
uint32_t bytesFromFile = sizeof(encodedBuffer);
|
||||||
if (_fileModule.PlayoutAudioData((WebRtc_Word8*)encodedBuffer,
|
if (_fileModule.PlayoutAudioData((int8_t*)encodedBuffer,
|
||||||
bytesFromFile) == -1)
|
bytesFromFile) == -1)
|
||||||
{
|
{
|
||||||
// End of file reached.
|
// End of file reached.
|
||||||
@ -171,7 +171,7 @@ WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
|||||||
encodedLengthInBytes = bytesFromFile;
|
encodedLengthInBytes = bytesFromFile;
|
||||||
}
|
}
|
||||||
if(_audioDecoder.Decode(unresampledAudioFrame,frequencyInHz,
|
if(_audioDecoder.Decode(unresampledAudioFrame,frequencyInHz,
|
||||||
(WebRtc_Word8*)encodedBuffer,
|
(int8_t*)encodedBuffer,
|
||||||
encodedLengthInBytes) == -1)
|
encodedLengthInBytes) == -1)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -187,7 +187,7 @@ WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
|||||||
|
|
||||||
// New sampling frequency. Update state.
|
// New sampling frequency. Update state.
|
||||||
outLen = frequencyInHz / 100;
|
outLen = frequencyInHz / 100;
|
||||||
memset(outBuffer, 0, outLen * sizeof(WebRtc_Word16));
|
memset(outBuffer, 0, outLen * sizeof(int16_t));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
_resampler.Push(unresampledAudioFrame.data_,
|
_resampler.Push(unresampledAudioFrame.data_,
|
||||||
@ -202,19 +202,19 @@ WebRtc_Word32 FilePlayerImpl::Get10msAudioFromFile(
|
|||||||
{
|
{
|
||||||
for (int i = 0;i < outLen; i++)
|
for (int i = 0;i < outLen; i++)
|
||||||
{
|
{
|
||||||
outBuffer[i] = (WebRtc_Word16)(outBuffer[i] * _scaling);
|
outBuffer[i] = (int16_t)(outBuffer[i] * _scaling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_decodedLengthInMS += 10;
|
_decodedLengthInMS += 10;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FilePlayerImpl::RegisterModuleFileCallback(FileCallback* callback)
|
int32_t FilePlayerImpl::RegisterModuleFileCallback(FileCallback* callback)
|
||||||
{
|
{
|
||||||
return _fileModule.SetModuleFileCallback(callback);
|
return _fileModule.SetModuleFileCallback(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FilePlayerImpl::SetAudioScaling(float scaleFactor)
|
int32_t FilePlayerImpl::SetAudioScaling(float scaleFactor)
|
||||||
{
|
{
|
||||||
if((scaleFactor >= 0)&&(scaleFactor <= 2.0))
|
if((scaleFactor >= 0)&&(scaleFactor <= 2.0))
|
||||||
{
|
{
|
||||||
@ -226,12 +226,12 @@ WebRtc_Word32 FilePlayerImpl::SetAudioScaling(float scaleFactor)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FilePlayerImpl::StartPlayingFile(const char* fileName,
|
int32_t FilePlayerImpl::StartPlayingFile(const char* fileName,
|
||||||
bool loop,
|
bool loop,
|
||||||
WebRtc_UWord32 startPosition,
|
uint32_t startPosition,
|
||||||
float volumeScaling,
|
float volumeScaling,
|
||||||
WebRtc_UWord32 notification,
|
uint32_t notification,
|
||||||
WebRtc_UWord32 stopPosition,
|
uint32_t stopPosition,
|
||||||
const CodecInst* codecInst)
|
const CodecInst* codecInst)
|
||||||
{
|
{
|
||||||
if (_fileFormat == kFileFormatPcm16kHzFile ||
|
if (_fileFormat == kFileFormatPcm16kHzFile ||
|
||||||
@ -322,11 +322,11 @@ WebRtc_Word32 FilePlayerImpl::StartPlayingFile(const char* fileName,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FilePlayerImpl::StartPlayingFile(InStream& sourceStream,
|
int32_t FilePlayerImpl::StartPlayingFile(InStream& sourceStream,
|
||||||
WebRtc_UWord32 startPosition,
|
uint32_t startPosition,
|
||||||
float volumeScaling,
|
float volumeScaling,
|
||||||
WebRtc_UWord32 notification,
|
uint32_t notification,
|
||||||
WebRtc_UWord32 stopPosition,
|
uint32_t stopPosition,
|
||||||
const CodecInst* codecInst)
|
const CodecInst* codecInst)
|
||||||
{
|
{
|
||||||
if (_fileFormat == kFileFormatPcm16kHzFile ||
|
if (_fileFormat == kFileFormatPcm16kHzFile ||
|
||||||
@ -415,7 +415,7 @@ WebRtc_Word32 FilePlayerImpl::StartPlayingFile(InStream& sourceStream,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FilePlayerImpl::StopPlayingFile()
|
int32_t FilePlayerImpl::StopPlayingFile()
|
||||||
{
|
{
|
||||||
memset(&_codec, 0, sizeof(CodecInst));
|
memset(&_codec, 0, sizeof(CodecInst));
|
||||||
_numberOf10MsPerFrame = 0;
|
_numberOf10MsPerFrame = 0;
|
||||||
@ -428,12 +428,12 @@ bool FilePlayerImpl::IsPlayingFile() const
|
|||||||
return _fileModule.IsPlaying();
|
return _fileModule.IsPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FilePlayerImpl::GetPlayoutPosition(WebRtc_UWord32& durationMs)
|
int32_t FilePlayerImpl::GetPlayoutPosition(uint32_t& durationMs)
|
||||||
{
|
{
|
||||||
return _fileModule.PlayoutPositionMs(durationMs);
|
return _fileModule.PlayoutPositionMs(durationMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FilePlayerImpl::SetUpAudioDecoder()
|
int32_t FilePlayerImpl::SetUpAudioDecoder()
|
||||||
{
|
{
|
||||||
if ((_fileModule.codec_info(_codec) == -1))
|
if ((_fileModule.codec_info(_codec) == -1))
|
||||||
{
|
{
|
||||||
@ -462,7 +462,7 @@ WebRtc_Word32 FilePlayerImpl::SetUpAudioDecoder()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WEBRTC_MODULE_UTILITY_VIDEO
|
#ifdef WEBRTC_MODULE_UTILITY_VIDEO
|
||||||
VideoFilePlayerImpl::VideoFilePlayerImpl(WebRtc_UWord32 instanceID,
|
VideoFilePlayerImpl::VideoFilePlayerImpl(uint32_t instanceID,
|
||||||
FileFormats fileFormat)
|
FileFormats fileFormat)
|
||||||
: FilePlayerImpl(instanceID,fileFormat),
|
: FilePlayerImpl(instanceID,fileFormat),
|
||||||
_videoDecoder(*new VideoCoder(instanceID)),
|
_videoDecoder(*new VideoCoder(instanceID)),
|
||||||
@ -488,7 +488,7 @@ VideoFilePlayerImpl::~VideoFilePlayerImpl()
|
|||||||
delete &_encodedData;
|
delete &_encodedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoFilePlayerImpl::StartPlayingVideoFile(
|
int32_t VideoFilePlayerImpl::StartPlayingVideoFile(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
bool loop,
|
bool loop,
|
||||||
bool videoOnly)
|
bool videoOnly)
|
||||||
@ -525,7 +525,7 @@ WebRtc_Word32 VideoFilePlayerImpl::StartPlayingVideoFile(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoFilePlayerImpl::StopPlayingFile()
|
int32_t VideoFilePlayerImpl::StopPlayingFile()
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock( _critSec);
|
CriticalSectionScoped lock( _critSec);
|
||||||
|
|
||||||
@ -535,13 +535,13 @@ WebRtc_Word32 VideoFilePlayerImpl::StopPlayingFile()
|
|||||||
return FilePlayerImpl::StopPlayingFile();
|
return FilePlayerImpl::StopPlayingFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame,
|
int32_t VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame,
|
||||||
WebRtc_UWord32 outWidth,
|
uint32_t outWidth,
|
||||||
WebRtc_UWord32 outHeight)
|
uint32_t outHeight)
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock( _critSec);
|
CriticalSectionScoped lock( _critSec);
|
||||||
|
|
||||||
WebRtc_Word32 retVal = GetVideoFromFile(videoFrame);
|
int32_t retVal = GetVideoFromFile(videoFrame);
|
||||||
if(retVal != 0)
|
if(retVal != 0)
|
||||||
{
|
{
|
||||||
return retVal;
|
return retVal;
|
||||||
@ -554,7 +554,7 @@ WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame,
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame)
|
int32_t VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame)
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock( _critSec);
|
CriticalSectionScoped lock( _critSec);
|
||||||
// No new video data read from file.
|
// No new video data read from file.
|
||||||
@ -563,7 +563,7 @@ WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame)
|
|||||||
videoFrame.ResetSize();
|
videoFrame.ResetSize();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
WebRtc_Word32 retVal = 0;
|
int32_t retVal = 0;
|
||||||
if(strncmp(video_codec_info_.plName, "I420", 5) == 0)
|
if(strncmp(video_codec_info_.plName, "I420", 5) == 0)
|
||||||
{
|
{
|
||||||
int size_y = video_codec_info_.width * video_codec_info_.height;
|
int size_y = video_codec_info_.width * video_codec_info_.height;
|
||||||
@ -588,7 +588,7 @@ WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame)
|
|||||||
retVal = _videoDecoder.Decode(videoFrame, _encodedData);
|
retVal = _videoDecoder.Decode(videoFrame, _encodedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word64 renderTimeMs = TickTime::MillisecondTimestamp();
|
int64_t renderTimeMs = TickTime::MillisecondTimestamp();
|
||||||
videoFrame.set_render_time_ms(renderTimeMs);
|
videoFrame.set_render_time_ms(renderTimeMs);
|
||||||
|
|
||||||
// Indicate that the current frame in the encoded buffer is old/has
|
// Indicate that the current frame in the encoded buffer is old/has
|
||||||
@ -601,7 +601,7 @@ WebRtc_Word32 VideoFilePlayerImpl::GetVideoFromFile(I420VideoFrame& videoFrame)
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoFilePlayerImpl::video_codec_info(
|
int32_t VideoFilePlayerImpl::video_codec_info(
|
||||||
VideoCodec& videoCodec) const
|
VideoCodec& videoCodec) const
|
||||||
{
|
{
|
||||||
if(video_codec_info_.plName[0] == 0)
|
if(video_codec_info_.plName[0] == 0)
|
||||||
@ -612,7 +612,7 @@ WebRtc_Word32 VideoFilePlayerImpl::video_codec_info(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
int32_t VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
||||||
{
|
{
|
||||||
if(_fileFormat != kFileFormatAviFile)
|
if(_fileFormat != kFileFormatAviFile)
|
||||||
{
|
{
|
||||||
@ -630,9 +630,9 @@ WebRtc_Word32 VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
|||||||
if(_fileFormat == kFileFormatAviFile)
|
if(_fileFormat == kFileFormatAviFile)
|
||||||
{
|
{
|
||||||
// Get next video frame
|
// Get next video frame
|
||||||
WebRtc_UWord32 encodedBufferLengthInBytes = _encodedData.bufferSize;
|
uint32_t encodedBufferLengthInBytes = _encodedData.bufferSize;
|
||||||
if(_fileModule.PlayoutAVIVideoData(
|
if(_fileModule.PlayoutAVIVideoData(
|
||||||
reinterpret_cast< WebRtc_Word8*>(_encodedData.payloadData),
|
reinterpret_cast< int8_t*>(_encodedData.payloadData),
|
||||||
encodedBufferLengthInBytes) != 0)
|
encodedBufferLengthInBytes) != 0)
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(
|
WEBRTC_TRACE(
|
||||||
@ -659,7 +659,7 @@ WebRtc_Word32 VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
|||||||
// Frame rate is in frames per seconds. Frame length is
|
// Frame rate is in frames per seconds. Frame length is
|
||||||
// calculated as an integer division which means it may
|
// calculated as an integer division which means it may
|
||||||
// be rounded down. Compensate for this every second.
|
// be rounded down. Compensate for this every second.
|
||||||
WebRtc_UWord32 rest = 1000%_frameLengthMS;
|
uint32_t rest = 1000%_frameLengthMS;
|
||||||
_accumulatedRenderTimeMs += rest;
|
_accumulatedRenderTimeMs += rest;
|
||||||
}
|
}
|
||||||
_accumulatedRenderTimeMs += _frameLengthMS;
|
_accumulatedRenderTimeMs += _frameLengthMS;
|
||||||
@ -667,7 +667,7 @@ WebRtc_Word32 VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word64 timeToNextFrame;
|
int64_t timeToNextFrame;
|
||||||
if(_videoOnly)
|
if(_videoOnly)
|
||||||
{
|
{
|
||||||
timeToNextFrame = _accumulatedRenderTimeMs -
|
timeToNextFrame = _accumulatedRenderTimeMs -
|
||||||
@ -686,10 +686,10 @@ WebRtc_Word32 VideoFilePlayerImpl::TimeUntilNextVideoFrame()
|
|||||||
// Wraparound or audio stream has gone to far ahead of the video stream.
|
// Wraparound or audio stream has gone to far ahead of the video stream.
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return static_cast<WebRtc_Word32>(timeToNextFrame);
|
return static_cast<int32_t>(timeToNextFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoFilePlayerImpl::SetUpVideoDecoder()
|
int32_t VideoFilePlayerImpl::SetUpVideoDecoder()
|
||||||
{
|
{
|
||||||
if (_fileModule.VideoCodecInst(video_codec_info_) != 0)
|
if (_fileModule.VideoCodecInst(video_codec_info_) != 0)
|
||||||
{
|
{
|
||||||
@ -702,7 +702,7 @@ WebRtc_Word32 VideoFilePlayerImpl::SetUpVideoDecoder()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 useNumberOfCores = 1;
|
int32_t useNumberOfCores = 1;
|
||||||
if(_videoDecoder.SetDecodeCodec(video_codec_info_, useNumberOfCores) != 0)
|
if(_videoDecoder.SetDecodeCodec(video_codec_info_, useNumberOfCores) != 0)
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(
|
WEBRTC_TRACE(
|
||||||
@ -718,7 +718,7 @@ WebRtc_Word32 VideoFilePlayerImpl::SetUpVideoDecoder()
|
|||||||
|
|
||||||
// Size of unencoded data (I420) should be the largest possible frame size
|
// Size of unencoded data (I420) should be the largest possible frame size
|
||||||
// in a file.
|
// in a file.
|
||||||
const WebRtc_UWord32 KReadBufferSize = 3 * video_codec_info_.width *
|
const uint32_t KReadBufferSize = 3 * video_codec_info_.width *
|
||||||
video_codec_info_.height / 2;
|
video_codec_info_.height / 2;
|
||||||
_encodedData.VerifyAndAllocate(KReadBufferSize);
|
_encodedData.VerifyAndAllocate(KReadBufferSize);
|
||||||
_encodedData.encodedHeight = video_codec_info_.height;
|
_encodedData.encodedHeight = video_codec_info_.height;
|
||||||
|
@ -29,51 +29,51 @@ class FrameScaler;
|
|||||||
class FilePlayerImpl : public FilePlayer
|
class FilePlayerImpl : public FilePlayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FilePlayerImpl(WebRtc_UWord32 instanceID, FileFormats fileFormat);
|
FilePlayerImpl(uint32_t instanceID, FileFormats fileFormat);
|
||||||
~FilePlayerImpl();
|
~FilePlayerImpl();
|
||||||
|
|
||||||
virtual int Get10msAudioFromFile(
|
virtual int Get10msAudioFromFile(
|
||||||
int16_t* outBuffer,
|
int16_t* outBuffer,
|
||||||
int& lengthInSamples,
|
int& lengthInSamples,
|
||||||
int frequencyInHz);
|
int frequencyInHz);
|
||||||
virtual WebRtc_Word32 RegisterModuleFileCallback(FileCallback* callback);
|
virtual int32_t RegisterModuleFileCallback(FileCallback* callback);
|
||||||
virtual WebRtc_Word32 StartPlayingFile(
|
virtual int32_t StartPlayingFile(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
bool loop,
|
bool loop,
|
||||||
WebRtc_UWord32 startPosition,
|
uint32_t startPosition,
|
||||||
float volumeScaling,
|
float volumeScaling,
|
||||||
WebRtc_UWord32 notification,
|
uint32_t notification,
|
||||||
WebRtc_UWord32 stopPosition = 0,
|
uint32_t stopPosition = 0,
|
||||||
const CodecInst* codecInst = NULL);
|
const CodecInst* codecInst = NULL);
|
||||||
virtual WebRtc_Word32 StartPlayingFile(
|
virtual int32_t StartPlayingFile(
|
||||||
InStream& sourceStream,
|
InStream& sourceStream,
|
||||||
WebRtc_UWord32 startPosition,
|
uint32_t startPosition,
|
||||||
float volumeScaling,
|
float volumeScaling,
|
||||||
WebRtc_UWord32 notification,
|
uint32_t notification,
|
||||||
WebRtc_UWord32 stopPosition = 0,
|
uint32_t stopPosition = 0,
|
||||||
const CodecInst* codecInst = NULL);
|
const CodecInst* codecInst = NULL);
|
||||||
virtual WebRtc_Word32 StopPlayingFile();
|
virtual int32_t StopPlayingFile();
|
||||||
virtual bool IsPlayingFile() const;
|
virtual bool IsPlayingFile() const;
|
||||||
virtual WebRtc_Word32 GetPlayoutPosition(WebRtc_UWord32& durationMs);
|
virtual int32_t GetPlayoutPosition(uint32_t& durationMs);
|
||||||
virtual WebRtc_Word32 AudioCodec(CodecInst& audioCodec) const;
|
virtual int32_t AudioCodec(CodecInst& audioCodec) const;
|
||||||
virtual WebRtc_Word32 Frequency() const;
|
virtual int32_t Frequency() const;
|
||||||
virtual WebRtc_Word32 SetAudioScaling(float scaleFactor);
|
virtual int32_t SetAudioScaling(float scaleFactor);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtc_Word32 SetUpAudioDecoder();
|
int32_t SetUpAudioDecoder();
|
||||||
|
|
||||||
WebRtc_UWord32 _instanceID;
|
uint32_t _instanceID;
|
||||||
const FileFormats _fileFormat;
|
const FileFormats _fileFormat;
|
||||||
MediaFile& _fileModule;
|
MediaFile& _fileModule;
|
||||||
|
|
||||||
WebRtc_UWord32 _decodedLengthInMS;
|
uint32_t _decodedLengthInMS;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioCoder _audioDecoder;
|
AudioCoder _audioDecoder;
|
||||||
|
|
||||||
CodecInst _codec;
|
CodecInst _codec;
|
||||||
WebRtc_Word32 _numberOf10MsPerFrame;
|
int32_t _numberOf10MsPerFrame;
|
||||||
WebRtc_Word32 _numberOf10MsInDecoder;
|
int32_t _numberOf10MsInDecoder;
|
||||||
|
|
||||||
Resampler _resampler;
|
Resampler _resampler;
|
||||||
float _scaling;
|
float _scaling;
|
||||||
@ -83,37 +83,37 @@ private:
|
|||||||
class VideoFilePlayerImpl: public FilePlayerImpl
|
class VideoFilePlayerImpl: public FilePlayerImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VideoFilePlayerImpl(WebRtc_UWord32 instanceID, FileFormats fileFormat);
|
VideoFilePlayerImpl(uint32_t instanceID, FileFormats fileFormat);
|
||||||
~VideoFilePlayerImpl();
|
~VideoFilePlayerImpl();
|
||||||
|
|
||||||
// FilePlayer functions.
|
// FilePlayer functions.
|
||||||
virtual WebRtc_Word32 TimeUntilNextVideoFrame();
|
virtual int32_t TimeUntilNextVideoFrame();
|
||||||
virtual WebRtc_Word32 StartPlayingVideoFile(const char* fileName,
|
virtual int32_t StartPlayingVideoFile(const char* fileName,
|
||||||
bool loop,
|
bool loop,
|
||||||
bool videoOnly);
|
bool videoOnly);
|
||||||
virtual WebRtc_Word32 StopPlayingFile();
|
virtual int32_t StopPlayingFile();
|
||||||
virtual WebRtc_Word32 video_codec_info(VideoCodec& videoCodec) const;
|
virtual int32_t video_codec_info(VideoCodec& videoCodec) const;
|
||||||
virtual WebRtc_Word32 GetVideoFromFile(I420VideoFrame& videoFrame);
|
virtual int32_t GetVideoFromFile(I420VideoFrame& videoFrame);
|
||||||
virtual WebRtc_Word32 GetVideoFromFile(I420VideoFrame& videoFrame,
|
virtual int32_t GetVideoFromFile(I420VideoFrame& videoFrame,
|
||||||
const WebRtc_UWord32 outWidth,
|
const uint32_t outWidth,
|
||||||
const WebRtc_UWord32 outHeight);
|
const uint32_t outHeight);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WebRtc_Word32 SetUpVideoDecoder();
|
int32_t SetUpVideoDecoder();
|
||||||
|
|
||||||
VideoCoder& _videoDecoder;
|
VideoCoder& _videoDecoder;
|
||||||
VideoCodec video_codec_info_;
|
VideoCodec video_codec_info_;
|
||||||
WebRtc_Word32 _decodedVideoFrames;
|
int32_t _decodedVideoFrames;
|
||||||
|
|
||||||
EncodedVideoData& _encodedData;
|
EncodedVideoData& _encodedData;
|
||||||
|
|
||||||
FrameScaler& _frameScaler;
|
FrameScaler& _frameScaler;
|
||||||
CriticalSectionWrapper* _critSec;
|
CriticalSectionWrapper* _critSec;
|
||||||
TickTime _startTime;
|
TickTime _startTime;
|
||||||
WebRtc_Word64 _accumulatedRenderTimeMs;
|
int64_t _accumulatedRenderTimeMs;
|
||||||
WebRtc_UWord32 _frameLengthMS;
|
uint32_t _frameLengthMS;
|
||||||
|
|
||||||
WebRtc_Word32 _numberOfFramesRead;
|
int32_t _numberOfFramesRead;
|
||||||
bool _videoOnly;
|
bool _videoOnly;
|
||||||
};
|
};
|
||||||
#endif //WEBRTC_MODULE_UTILITY_VIDEO
|
#endif //WEBRTC_MODULE_UTILITY_VIDEO
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
FileRecorder* FileRecorder::CreateFileRecorder(WebRtc_UWord32 instanceID,
|
FileRecorder* FileRecorder::CreateFileRecorder(uint32_t instanceID,
|
||||||
FileFormats fileFormat)
|
FileFormats fileFormat)
|
||||||
{
|
{
|
||||||
switch(fileFormat)
|
switch(fileFormat)
|
||||||
@ -60,7 +60,7 @@ void FileRecorder::DestroyFileRecorder(FileRecorder* recorder)
|
|||||||
delete recorder;
|
delete recorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileRecorderImpl::FileRecorderImpl(WebRtc_UWord32 instanceID,
|
FileRecorderImpl::FileRecorderImpl(uint32_t instanceID,
|
||||||
FileFormats fileFormat)
|
FileFormats fileFormat)
|
||||||
: _instanceID(instanceID),
|
: _instanceID(instanceID),
|
||||||
_fileFormat(fileFormat),
|
_fileFormat(fileFormat),
|
||||||
@ -83,7 +83,7 @@ FileFormats FileRecorderImpl::RecordingFileFormat() const
|
|||||||
return _fileFormat;
|
return _fileFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FileRecorderImpl::RegisterModuleFileCallback(
|
int32_t FileRecorderImpl::RegisterModuleFileCallback(
|
||||||
FileCallback* callback)
|
FileCallback* callback)
|
||||||
{
|
{
|
||||||
if(_moduleFile == NULL)
|
if(_moduleFile == NULL)
|
||||||
@ -93,10 +93,10 @@ WebRtc_Word32 FileRecorderImpl::RegisterModuleFileCallback(
|
|||||||
return _moduleFile->SetModuleFileCallback(callback);
|
return _moduleFile->SetModuleFileCallback(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FileRecorderImpl::StartRecordingAudioFile(
|
int32_t FileRecorderImpl::StartRecordingAudioFile(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
const CodecInst& codecInst,
|
const CodecInst& codecInst,
|
||||||
WebRtc_UWord32 notificationTimeMs,
|
uint32_t notificationTimeMs,
|
||||||
ACMAMRPackingFormat amrFormat)
|
ACMAMRPackingFormat amrFormat)
|
||||||
{
|
{
|
||||||
if(_moduleFile == NULL)
|
if(_moduleFile == NULL)
|
||||||
@ -106,7 +106,7 @@ WebRtc_Word32 FileRecorderImpl::StartRecordingAudioFile(
|
|||||||
codec_info_ = codecInst;
|
codec_info_ = codecInst;
|
||||||
_amrFormat = amrFormat;
|
_amrFormat = amrFormat;
|
||||||
|
|
||||||
WebRtc_Word32 retVal = 0;
|
int32_t retVal = 0;
|
||||||
if(_fileFormat != kFileFormatAviFile)
|
if(_fileFormat != kFileFormatAviFile)
|
||||||
{
|
{
|
||||||
// AVI files should be started using StartRecordingVideoFile(..) all
|
// AVI files should be started using StartRecordingVideoFile(..) all
|
||||||
@ -138,16 +138,16 @@ WebRtc_Word32 FileRecorderImpl::StartRecordingAudioFile(
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FileRecorderImpl::StartRecordingAudioFile(
|
int32_t FileRecorderImpl::StartRecordingAudioFile(
|
||||||
OutStream& destStream,
|
OutStream& destStream,
|
||||||
const CodecInst& codecInst,
|
const CodecInst& codecInst,
|
||||||
WebRtc_UWord32 notificationTimeMs,
|
uint32_t notificationTimeMs,
|
||||||
ACMAMRPackingFormat amrFormat)
|
ACMAMRPackingFormat amrFormat)
|
||||||
{
|
{
|
||||||
codec_info_ = codecInst;
|
codec_info_ = codecInst;
|
||||||
_amrFormat = amrFormat;
|
_amrFormat = amrFormat;
|
||||||
|
|
||||||
WebRtc_Word32 retVal = _moduleFile->StartRecordingAudioStream(
|
int32_t retVal = _moduleFile->StartRecordingAudioStream(
|
||||||
destStream,
|
destStream,
|
||||||
_fileFormat,
|
_fileFormat,
|
||||||
codecInst,
|
codecInst,
|
||||||
@ -174,7 +174,7 @@ WebRtc_Word32 FileRecorderImpl::StartRecordingAudioFile(
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FileRecorderImpl::StopRecording()
|
int32_t FileRecorderImpl::StopRecording()
|
||||||
{
|
{
|
||||||
memset(&codec_info_, 0, sizeof(CodecInst));
|
memset(&codec_info_, 0, sizeof(CodecInst));
|
||||||
return _moduleFile->StopRecording();
|
return _moduleFile->StopRecording();
|
||||||
@ -185,7 +185,7 @@ bool FileRecorderImpl::IsRecording() const
|
|||||||
return _moduleFile->IsRecording();
|
return _moduleFile->IsRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
int32_t FileRecorderImpl::RecordAudioToFile(
|
||||||
const AudioFrame& incomingAudioFrame,
|
const AudioFrame& incomingAudioFrame,
|
||||||
const TickTime* playoutTS)
|
const TickTime* playoutTS)
|
||||||
{
|
{
|
||||||
@ -209,7 +209,7 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
|||||||
tempAudioFrame.sample_rate_hz_ = incomingAudioFrame.sample_rate_hz_;
|
tempAudioFrame.sample_rate_hz_ = incomingAudioFrame.sample_rate_hz_;
|
||||||
tempAudioFrame.samples_per_channel_ =
|
tempAudioFrame.samples_per_channel_ =
|
||||||
incomingAudioFrame.samples_per_channel_;
|
incomingAudioFrame.samples_per_channel_;
|
||||||
for (WebRtc_UWord16 i = 0;
|
for (uint16_t i = 0;
|
||||||
i < (incomingAudioFrame.samples_per_channel_); i++)
|
i < (incomingAudioFrame.samples_per_channel_); i++)
|
||||||
{
|
{
|
||||||
// Sample value is the average of left and right buffer rounded to
|
// Sample value is the average of left and right buffer rounded to
|
||||||
@ -227,7 +227,7 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
|||||||
tempAudioFrame.sample_rate_hz_ = incomingAudioFrame.sample_rate_hz_;
|
tempAudioFrame.sample_rate_hz_ = incomingAudioFrame.sample_rate_hz_;
|
||||||
tempAudioFrame.samples_per_channel_ =
|
tempAudioFrame.samples_per_channel_ =
|
||||||
incomingAudioFrame.samples_per_channel_;
|
incomingAudioFrame.samples_per_channel_;
|
||||||
for (WebRtc_UWord16 i = 0;
|
for (uint16_t i = 0;
|
||||||
i < (incomingAudioFrame.samples_per_channel_); i++)
|
i < (incomingAudioFrame.samples_per_channel_); i++)
|
||||||
{
|
{
|
||||||
// Duplicate sample to both channels
|
// Duplicate sample to both channels
|
||||||
@ -250,7 +250,7 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
|||||||
// NOTE: stereo recording is only supported for WAV files.
|
// NOTE: stereo recording is only supported for WAV files.
|
||||||
// TODO (hellner): WAV expect PCM in little endian byte order. Not
|
// TODO (hellner): WAV expect PCM in little endian byte order. Not
|
||||||
// "encoding" with PCM coder should be a problem for big endian systems.
|
// "encoding" with PCM coder should be a problem for big endian systems.
|
||||||
WebRtc_UWord32 encodedLenInBytes = 0;
|
uint32_t encodedLenInBytes = 0;
|
||||||
if (_fileFormat == kFileFormatPreencodedFile ||
|
if (_fileFormat == kFileFormatPreencodedFile ||
|
||||||
STR_CASE_CMP(codec_info_.plname, "L16") != 0)
|
STR_CASE_CMP(codec_info_.plname, "L16") != 0)
|
||||||
{
|
{
|
||||||
@ -277,7 +277,7 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
|||||||
_audioResampler.Push(ptrAudioFrame->data_,
|
_audioResampler.Push(ptrAudioFrame->data_,
|
||||||
ptrAudioFrame->samples_per_channel_ *
|
ptrAudioFrame->samples_per_channel_ *
|
||||||
ptrAudioFrame->num_channels_,
|
ptrAudioFrame->num_channels_,
|
||||||
(WebRtc_Word16*)_audioBuffer,
|
(int16_t*)_audioBuffer,
|
||||||
MAX_AUDIO_BUFFER_IN_BYTES, outLen);
|
MAX_AUDIO_BUFFER_IN_BYTES, outLen);
|
||||||
} else {
|
} else {
|
||||||
_audioResampler.ResetIfNeeded(ptrAudioFrame->sample_rate_hz_,
|
_audioResampler.ResetIfNeeded(ptrAudioFrame->sample_rate_hz_,
|
||||||
@ -285,10 +285,10 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
|||||||
kResamplerSynchronous);
|
kResamplerSynchronous);
|
||||||
_audioResampler.Push(ptrAudioFrame->data_,
|
_audioResampler.Push(ptrAudioFrame->data_,
|
||||||
ptrAudioFrame->samples_per_channel_,
|
ptrAudioFrame->samples_per_channel_,
|
||||||
(WebRtc_Word16*)_audioBuffer,
|
(int16_t*)_audioBuffer,
|
||||||
MAX_AUDIO_BUFFER_IN_BYTES, outLen);
|
MAX_AUDIO_BUFFER_IN_BYTES, outLen);
|
||||||
}
|
}
|
||||||
encodedLenInBytes = outLen * sizeof(WebRtc_Word16);
|
encodedLenInBytes = outLen * sizeof(int16_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Codec may not be operating at a frame rate of 10 ms. Whenever enough
|
// Codec may not be operating at a frame rate of 10 ms. Whenever enough
|
||||||
@ -296,11 +296,11 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
|||||||
// will be available. Wait until then.
|
// will be available. Wait until then.
|
||||||
if (encodedLenInBytes)
|
if (encodedLenInBytes)
|
||||||
{
|
{
|
||||||
WebRtc_UWord16 msOfData =
|
uint16_t msOfData =
|
||||||
ptrAudioFrame->samples_per_channel_ /
|
ptrAudioFrame->samples_per_channel_ /
|
||||||
WebRtc_UWord16(ptrAudioFrame->sample_rate_hz_ / 1000);
|
uint16_t(ptrAudioFrame->sample_rate_hz_ / 1000);
|
||||||
if (WriteEncodedAudioData(_audioBuffer,
|
if (WriteEncodedAudioData(_audioBuffer,
|
||||||
(WebRtc_UWord16)encodedLenInBytes,
|
(uint16_t)encodedLenInBytes,
|
||||||
msOfData, playoutTS) == -1)
|
msOfData, playoutTS) == -1)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -309,7 +309,7 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FileRecorderImpl::SetUpAudioEncoder()
|
int32_t FileRecorderImpl::SetUpAudioEncoder()
|
||||||
{
|
{
|
||||||
if (_fileFormat == kFileFormatPreencodedFile ||
|
if (_fileFormat == kFileFormatPreencodedFile ||
|
||||||
STR_CASE_CMP(codec_info_.plname, "L16") != 0)
|
STR_CASE_CMP(codec_info_.plname, "L16") != 0)
|
||||||
@ -328,7 +328,7 @@ WebRtc_Word32 FileRecorderImpl::SetUpAudioEncoder()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FileRecorderImpl::codec_info(CodecInst& codecInst) const
|
int32_t FileRecorderImpl::codec_info(CodecInst& codecInst) const
|
||||||
{
|
{
|
||||||
if(codec_info_.plfreq == 0)
|
if(codec_info_.plfreq == 0)
|
||||||
{
|
{
|
||||||
@ -338,10 +338,10 @@ WebRtc_Word32 FileRecorderImpl::codec_info(CodecInst& codecInst) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 FileRecorderImpl::WriteEncodedAudioData(
|
int32_t FileRecorderImpl::WriteEncodedAudioData(
|
||||||
const WebRtc_Word8* audioBuffer,
|
const int8_t* audioBuffer,
|
||||||
WebRtc_UWord16 bufferLength,
|
uint16_t bufferLength,
|
||||||
WebRtc_UWord16 /*millisecondsOfData*/,
|
uint16_t /*millisecondsOfData*/,
|
||||||
const TickTime* /*playoutTS*/)
|
const TickTime* /*playoutTS*/)
|
||||||
{
|
{
|
||||||
return _moduleFile->IncomingAudioData(audioBuffer, bufferLength);
|
return _moduleFile->IncomingAudioData(audioBuffer, bufferLength);
|
||||||
@ -352,9 +352,9 @@ WebRtc_Word32 FileRecorderImpl::WriteEncodedAudioData(
|
|||||||
class AudioFrameFileInfo
|
class AudioFrameFileInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioFrameFileInfo(const WebRtc_Word8* audioData,
|
AudioFrameFileInfo(const int8_t* audioData,
|
||||||
const WebRtc_UWord16 audioSize,
|
const uint16_t audioSize,
|
||||||
const WebRtc_UWord16 audioMS,
|
const uint16_t audioMS,
|
||||||
const TickTime& playoutTS)
|
const TickTime& playoutTS)
|
||||||
: _audioData(), _audioSize(audioSize), _audioMS(audioMS),
|
: _audioData(), _audioSize(audioSize), _audioMS(audioMS),
|
||||||
_playoutTS(playoutTS)
|
_playoutTS(playoutTS)
|
||||||
@ -368,13 +368,13 @@ class AudioFrameFileInfo
|
|||||||
memcpy(_audioData, audioData, audioSize);
|
memcpy(_audioData, audioData, audioSize);
|
||||||
};
|
};
|
||||||
// TODO (hellner): either turn into a struct or provide get/set functions.
|
// TODO (hellner): either turn into a struct or provide get/set functions.
|
||||||
WebRtc_Word8 _audioData[MAX_AUDIO_BUFFER_IN_BYTES];
|
int8_t _audioData[MAX_AUDIO_BUFFER_IN_BYTES];
|
||||||
WebRtc_UWord16 _audioSize;
|
uint16_t _audioSize;
|
||||||
WebRtc_UWord16 _audioMS;
|
uint16_t _audioMS;
|
||||||
TickTime _playoutTS;
|
TickTime _playoutTS;
|
||||||
};
|
};
|
||||||
|
|
||||||
AviRecorder::AviRecorder(WebRtc_UWord32 instanceID, FileFormats fileFormat)
|
AviRecorder::AviRecorder(uint32_t instanceID, FileFormats fileFormat)
|
||||||
: FileRecorderImpl(instanceID, fileFormat),
|
: FileRecorderImpl(instanceID, fileFormat),
|
||||||
_videoOnly(false),
|
_videoOnly(false),
|
||||||
_thread( 0),
|
_thread( 0),
|
||||||
@ -403,7 +403,7 @@ AviRecorder::~AviRecorder( )
|
|||||||
delete _critSec;
|
delete _critSec;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AviRecorder::StartRecordingVideoFile(
|
int32_t AviRecorder::StartRecordingVideoFile(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
const CodecInst& audioCodecInst,
|
const CodecInst& audioCodecInst,
|
||||||
const VideoCodec& videoCodecInst,
|
const VideoCodec& videoCodecInst,
|
||||||
@ -446,7 +446,7 @@ WebRtc_Word32 AviRecorder::StartRecordingVideoFile(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AviRecorder::StopRecording()
|
int32_t AviRecorder::StopRecording()
|
||||||
{
|
{
|
||||||
_timeEvent.StopTimer();
|
_timeEvent.StopTimer();
|
||||||
|
|
||||||
@ -454,12 +454,12 @@ WebRtc_Word32 AviRecorder::StopRecording()
|
|||||||
return FileRecorderImpl::StopRecording();
|
return FileRecorderImpl::StopRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AviRecorder::CalcI420FrameSize( ) const
|
int32_t AviRecorder::CalcI420FrameSize( ) const
|
||||||
{
|
{
|
||||||
return 3 * _videoCodecInst.width * _videoCodecInst.height / 2;
|
return 3 * _videoCodecInst.width * _videoCodecInst.height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AviRecorder::SetUpVideoEncoder()
|
int32_t AviRecorder::SetUpVideoEncoder()
|
||||||
{
|
{
|
||||||
// Size of unencoded data (I420) should be the largest possible frame size
|
// Size of unencoded data (I420) should be the largest possible frame size
|
||||||
// in a file.
|
// in a file.
|
||||||
@ -469,7 +469,7 @@ WebRtc_Word32 AviRecorder::SetUpVideoEncoder()
|
|||||||
_videoCodecInst.plType = _videoEncoder->DefaultPayloadType(
|
_videoCodecInst.plType = _videoEncoder->DefaultPayloadType(
|
||||||
_videoCodecInst.plName);
|
_videoCodecInst.plName);
|
||||||
|
|
||||||
WebRtc_Word32 useNumberOfCores = 1;
|
int32_t useNumberOfCores = 1;
|
||||||
// Set the max payload size to 16000. This means that the codec will try to
|
// Set the max payload size to 16000. This means that the codec will try to
|
||||||
// create slices that will fit in 16000 kByte packets. However, the
|
// create slices that will fit in 16000 kByte packets. However, the
|
||||||
// Encode() call will still generate one full frame.
|
// Encode() call will still generate one full frame.
|
||||||
@ -481,7 +481,7 @@ WebRtc_Word32 AviRecorder::SetUpVideoEncoder()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AviRecorder::RecordVideoToFile(const I420VideoFrame& videoFrame)
|
int32_t AviRecorder::RecordVideoToFile(const I420VideoFrame& videoFrame)
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock(_critSec);
|
CriticalSectionScoped lock(_critSec);
|
||||||
if(!IsRecording() || videoFrame.IsZeroSize())
|
if(!IsRecording() || videoFrame.IsZeroSize())
|
||||||
@ -489,7 +489,7 @@ WebRtc_Word32 AviRecorder::RecordVideoToFile(const I420VideoFrame& videoFrame)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// The frame is written to file in AviRecorder::Process().
|
// The frame is written to file in AviRecorder::Process().
|
||||||
WebRtc_Word32 retVal = _videoFramesQueue->AddFrame(videoFrame);
|
int32_t retVal = _videoFramesQueue->AddFrame(videoFrame);
|
||||||
if(retVal != 0)
|
if(retVal != 0)
|
||||||
{
|
{
|
||||||
StopRecording();
|
StopRecording();
|
||||||
@ -540,7 +540,7 @@ bool AviRecorder::Run( ThreadObj threadObj)
|
|||||||
return static_cast<AviRecorder*>( threadObj)->Process();
|
return static_cast<AviRecorder*>( threadObj)->Process();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AviRecorder::ProcessAudio()
|
int32_t AviRecorder::ProcessAudio()
|
||||||
{
|
{
|
||||||
if (_writtenVideoFramesCounter == 0)
|
if (_writtenVideoFramesCounter == 0)
|
||||||
{
|
{
|
||||||
@ -552,9 +552,9 @@ WebRtc_Word32 AviRecorder::ProcessAudio()
|
|||||||
{
|
{
|
||||||
// Syncronize audio to the current frame to process by throwing away
|
// Syncronize audio to the current frame to process by throwing away
|
||||||
// audio samples with older timestamp than the video frame.
|
// audio samples with older timestamp than the video frame.
|
||||||
WebRtc_UWord32 numberOfAudioElements =
|
uint32_t numberOfAudioElements =
|
||||||
_audioFramesToWrite.GetSize();
|
_audioFramesToWrite.GetSize();
|
||||||
for (WebRtc_UWord32 i = 0; i < numberOfAudioElements; ++i)
|
for (uint32_t i = 0; i < numberOfAudioElements; ++i)
|
||||||
{
|
{
|
||||||
AudioFrameFileInfo* frameInfo =
|
AudioFrameFileInfo* frameInfo =
|
||||||
(AudioFrameFileInfo*)_audioFramesToWrite.First()->GetItem();
|
(AudioFrameFileInfo*)_audioFramesToWrite.First()->GetItem();
|
||||||
@ -575,9 +575,9 @@ WebRtc_Word32 AviRecorder::ProcessAudio()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Write all audio up to current timestamp.
|
// Write all audio up to current timestamp.
|
||||||
WebRtc_Word32 error = 0;
|
int32_t error = 0;
|
||||||
WebRtc_UWord32 numberOfAudioElements = _audioFramesToWrite.GetSize();
|
uint32_t numberOfAudioElements = _audioFramesToWrite.GetSize();
|
||||||
for (WebRtc_UWord32 i = 0; i < numberOfAudioElements; ++i)
|
for (uint32_t i = 0; i < numberOfAudioElements; ++i)
|
||||||
{
|
{
|
||||||
AudioFrameFileInfo* frameInfo =
|
AudioFrameFileInfo* frameInfo =
|
||||||
(AudioFrameFileInfo*)_audioFramesToWrite.First()->GetItem();
|
(AudioFrameFileInfo*)_audioFramesToWrite.First()->GetItem();
|
||||||
@ -626,7 +626,7 @@ bool AviRecorder::Process()
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
WebRtc_Word32 error = 0;
|
int32_t error = 0;
|
||||||
if(!_videoOnly)
|
if(!_videoOnly)
|
||||||
{
|
{
|
||||||
if(!_firstAudioFrameReceived)
|
if(!_firstAudioFrameReceived)
|
||||||
@ -646,7 +646,7 @@ bool AviRecorder::Process()
|
|||||||
"AviRecorder::Process() error writing to file.");
|
"AviRecorder::Process() error writing to file.");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
WebRtc_UWord32 frameLengthMS = 1000 /
|
uint32_t frameLengthMS = 1000 /
|
||||||
_videoCodecInst.maxFramerate;
|
_videoCodecInst.maxFramerate;
|
||||||
_writtenVideoFramesCounter++;
|
_writtenVideoFramesCounter++;
|
||||||
_writtenVideoMS += frameLengthMS;
|
_writtenVideoMS += frameLengthMS;
|
||||||
@ -656,7 +656,7 @@ bool AviRecorder::Process()
|
|||||||
// Frame rate is in frames per seconds. Frame length is
|
// Frame rate is in frames per seconds. Frame length is
|
||||||
// calculated as an integer division which means it may
|
// calculated as an integer division which means it may
|
||||||
// be rounded down. Compensate for this every second.
|
// be rounded down. Compensate for this every second.
|
||||||
WebRtc_UWord32 rest = 1000 % frameLengthMS;
|
uint32_t rest = 1000 % frameLengthMS;
|
||||||
_writtenVideoMS += rest;
|
_writtenVideoMS += rest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -667,9 +667,9 @@ bool AviRecorder::Process()
|
|||||||
// drift. Once a full frame worth of drift has happened, skip writing
|
// drift. Once a full frame worth of drift has happened, skip writing
|
||||||
// one frame. Note that frame rate is in frames per second so the
|
// one frame. Note that frame rate is in frames per second so the
|
||||||
// drift is completely compensated for.
|
// drift is completely compensated for.
|
||||||
WebRtc_UWord32 frameLengthMS = 1000/_videoCodecInst.maxFramerate;
|
uint32_t frameLengthMS = 1000/_videoCodecInst.maxFramerate;
|
||||||
WebRtc_UWord32 restMS = 1000 % frameLengthMS;
|
uint32_t restMS = 1000 % frameLengthMS;
|
||||||
WebRtc_UWord32 frameSkip = (_videoCodecInst.maxFramerate *
|
uint32_t frameSkip = (_videoCodecInst.maxFramerate *
|
||||||
frameLengthMS) / restMS;
|
frameLengthMS) / restMS;
|
||||||
|
|
||||||
_writtenVideoFramesCounter++;
|
_writtenVideoFramesCounter++;
|
||||||
@ -691,7 +691,7 @@ bool AviRecorder::Process()
|
|||||||
return error == 0;
|
return error == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 AviRecorder::EncodeAndWriteVideoToFile(I420VideoFrame& videoFrame)
|
int32_t AviRecorder::EncodeAndWriteVideoToFile(I420VideoFrame& videoFrame)
|
||||||
{
|
{
|
||||||
if (!IsRecording() || videoFrame.IsZeroSize())
|
if (!IsRecording() || videoFrame.IsZeroSize())
|
||||||
{
|
{
|
||||||
@ -731,7 +731,7 @@ WebRtc_Word32 AviRecorder::EncodeAndWriteVideoToFile(I420VideoFrame& videoFrame)
|
|||||||
if(_videoEncodedData.payloadSize > 0)
|
if(_videoEncodedData.payloadSize > 0)
|
||||||
{
|
{
|
||||||
if(_moduleFile->IncomingAVIVideoData(
|
if(_moduleFile->IncomingAVIVideoData(
|
||||||
(WebRtc_Word8*)(_videoEncodedData.payloadData),
|
(int8_t*)(_videoEncodedData.payloadData),
|
||||||
_videoEncodedData.payloadSize))
|
_videoEncodedData.payloadSize))
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideo, _instanceID,
|
WEBRTC_TRACE(kTraceError, kTraceVideo, _instanceID,
|
||||||
@ -751,10 +751,10 @@ WebRtc_Word32 AviRecorder::EncodeAndWriteVideoToFile(I420VideoFrame& videoFrame)
|
|||||||
|
|
||||||
// Store audio frame in the _audioFramesToWrite buffer. The writing to file
|
// Store audio frame in the _audioFramesToWrite buffer. The writing to file
|
||||||
// happens in AviRecorder::Process().
|
// happens in AviRecorder::Process().
|
||||||
WebRtc_Word32 AviRecorder::WriteEncodedAudioData(
|
int32_t AviRecorder::WriteEncodedAudioData(
|
||||||
const WebRtc_Word8* audioBuffer,
|
const int8_t* audioBuffer,
|
||||||
WebRtc_UWord16 bufferLength,
|
uint16_t bufferLength,
|
||||||
WebRtc_UWord16 millisecondsOfData,
|
uint16_t millisecondsOfData,
|
||||||
const TickTime* playoutTS)
|
const TickTime* playoutTS)
|
||||||
{
|
{
|
||||||
if (!IsRecording())
|
if (!IsRecording())
|
||||||
|
@ -43,29 +43,29 @@ enum { kMaxAudioBufferQueueLength = 100 };
|
|||||||
class FileRecorderImpl : public FileRecorder
|
class FileRecorderImpl : public FileRecorder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileRecorderImpl(WebRtc_UWord32 instanceID, FileFormats fileFormat);
|
FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat);
|
||||||
virtual ~FileRecorderImpl();
|
virtual ~FileRecorderImpl();
|
||||||
|
|
||||||
// FileRecorder functions.
|
// FileRecorder functions.
|
||||||
virtual WebRtc_Word32 RegisterModuleFileCallback(FileCallback* callback);
|
virtual int32_t RegisterModuleFileCallback(FileCallback* callback);
|
||||||
virtual FileFormats RecordingFileFormat() const;
|
virtual FileFormats RecordingFileFormat() const;
|
||||||
virtual WebRtc_Word32 StartRecordingAudioFile(
|
virtual int32_t StartRecordingAudioFile(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
const CodecInst& codecInst,
|
const CodecInst& codecInst,
|
||||||
WebRtc_UWord32 notificationTimeMs,
|
uint32_t notificationTimeMs,
|
||||||
ACMAMRPackingFormat amrFormat = AMRFileStorage);
|
ACMAMRPackingFormat amrFormat = AMRFileStorage);
|
||||||
virtual WebRtc_Word32 StartRecordingAudioFile(
|
virtual int32_t StartRecordingAudioFile(
|
||||||
OutStream& destStream,
|
OutStream& destStream,
|
||||||
const CodecInst& codecInst,
|
const CodecInst& codecInst,
|
||||||
WebRtc_UWord32 notificationTimeMs,
|
uint32_t notificationTimeMs,
|
||||||
ACMAMRPackingFormat amrFormat = AMRFileStorage);
|
ACMAMRPackingFormat amrFormat = AMRFileStorage);
|
||||||
virtual WebRtc_Word32 StopRecording();
|
virtual int32_t StopRecording();
|
||||||
virtual bool IsRecording() const;
|
virtual bool IsRecording() const;
|
||||||
virtual WebRtc_Word32 codec_info(CodecInst& codecInst) const;
|
virtual int32_t codec_info(CodecInst& codecInst) const;
|
||||||
virtual WebRtc_Word32 RecordAudioToFile(
|
virtual int32_t RecordAudioToFile(
|
||||||
const AudioFrame& frame,
|
const AudioFrame& frame,
|
||||||
const TickTime* playoutTS = NULL);
|
const TickTime* playoutTS = NULL);
|
||||||
virtual WebRtc_Word32 StartRecordingVideoFile(
|
virtual int32_t StartRecordingVideoFile(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
const CodecInst& audioCodecInst,
|
const CodecInst& audioCodecInst,
|
||||||
const VideoCodec& videoCodecInst,
|
const VideoCodec& videoCodecInst,
|
||||||
@ -74,21 +74,21 @@ public:
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
virtual WebRtc_Word32 RecordVideoToFile(const I420VideoFrame& videoFrame)
|
virtual int32_t RecordVideoToFile(const I420VideoFrame& videoFrame)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual WebRtc_Word32 WriteEncodedAudioData(
|
virtual int32_t WriteEncodedAudioData(
|
||||||
const WebRtc_Word8* audioBuffer,
|
const int8_t* audioBuffer,
|
||||||
WebRtc_UWord16 bufferLength,
|
uint16_t bufferLength,
|
||||||
WebRtc_UWord16 millisecondsOfData,
|
uint16_t millisecondsOfData,
|
||||||
const TickTime* playoutTS);
|
const TickTime* playoutTS);
|
||||||
|
|
||||||
WebRtc_Word32 SetUpAudioEncoder();
|
int32_t SetUpAudioEncoder();
|
||||||
|
|
||||||
WebRtc_UWord32 _instanceID;
|
uint32_t _instanceID;
|
||||||
FileFormats _fileFormat;
|
FileFormats _fileFormat;
|
||||||
MediaFile* _moduleFile;
|
MediaFile* _moduleFile;
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ private:
|
|||||||
CodecInst codec_info_;
|
CodecInst codec_info_;
|
||||||
ACMAMRPackingFormat _amrFormat;
|
ACMAMRPackingFormat _amrFormat;
|
||||||
|
|
||||||
WebRtc_Word8 _audioBuffer[MAX_AUDIO_BUFFER_IN_BYTES];
|
int8_t _audioBuffer[MAX_AUDIO_BUFFER_IN_BYTES];
|
||||||
AudioCoder _audioEncoder;
|
AudioCoder _audioEncoder;
|
||||||
Resampler _audioResampler;
|
Resampler _audioResampler;
|
||||||
};
|
};
|
||||||
@ -106,24 +106,24 @@ private:
|
|||||||
class AviRecorder : public FileRecorderImpl
|
class AviRecorder : public FileRecorderImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AviRecorder(WebRtc_UWord32 instanceID, FileFormats fileFormat);
|
AviRecorder(uint32_t instanceID, FileFormats fileFormat);
|
||||||
virtual ~AviRecorder();
|
virtual ~AviRecorder();
|
||||||
|
|
||||||
// FileRecorder functions.
|
// FileRecorder functions.
|
||||||
virtual WebRtc_Word32 StartRecordingVideoFile(
|
virtual int32_t StartRecordingVideoFile(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
const CodecInst& audioCodecInst,
|
const CodecInst& audioCodecInst,
|
||||||
const VideoCodec& videoCodecInst,
|
const VideoCodec& videoCodecInst,
|
||||||
ACMAMRPackingFormat amrFormat = AMRFileStorage,
|
ACMAMRPackingFormat amrFormat = AMRFileStorage,
|
||||||
bool videoOnly = false);
|
bool videoOnly = false);
|
||||||
virtual WebRtc_Word32 StopRecording();
|
virtual int32_t StopRecording();
|
||||||
virtual WebRtc_Word32 RecordVideoToFile(const I420VideoFrame& videoFrame);
|
virtual int32_t RecordVideoToFile(const I420VideoFrame& videoFrame);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual WebRtc_Word32 WriteEncodedAudioData(
|
virtual int32_t WriteEncodedAudioData(
|
||||||
const WebRtc_Word8* audioBuffer,
|
const int8_t* audioBuffer,
|
||||||
WebRtc_UWord16 bufferLength,
|
uint16_t bufferLength,
|
||||||
WebRtc_UWord16 millisecondsOfData,
|
uint16_t millisecondsOfData,
|
||||||
const TickTime* playoutTS);
|
const TickTime* playoutTS);
|
||||||
private:
|
private:
|
||||||
static bool Run(ThreadObj threadObj);
|
static bool Run(ThreadObj threadObj);
|
||||||
@ -132,11 +132,11 @@ private:
|
|||||||
bool StartThread();
|
bool StartThread();
|
||||||
bool StopThread();
|
bool StopThread();
|
||||||
|
|
||||||
WebRtc_Word32 EncodeAndWriteVideoToFile(I420VideoFrame& videoFrame);
|
int32_t EncodeAndWriteVideoToFile(I420VideoFrame& videoFrame);
|
||||||
WebRtc_Word32 ProcessAudio();
|
int32_t ProcessAudio();
|
||||||
|
|
||||||
WebRtc_Word32 CalcI420FrameSize() const;
|
int32_t CalcI420FrameSize() const;
|
||||||
WebRtc_Word32 SetUpVideoEncoder();
|
int32_t SetUpVideoEncoder();
|
||||||
|
|
||||||
VideoCodec _videoCodecInst;
|
VideoCodec _videoCodecInst;
|
||||||
bool _videoOnly;
|
bool _videoOnly;
|
||||||
@ -148,15 +148,15 @@ private:
|
|||||||
|
|
||||||
FrameScaler* _frameScaler;
|
FrameScaler* _frameScaler;
|
||||||
VideoCoder* _videoEncoder;
|
VideoCoder* _videoEncoder;
|
||||||
WebRtc_Word32 _videoMaxPayloadSize;
|
int32_t _videoMaxPayloadSize;
|
||||||
EncodedVideoData _videoEncodedData;
|
EncodedVideoData _videoEncodedData;
|
||||||
|
|
||||||
ThreadWrapper* _thread;
|
ThreadWrapper* _thread;
|
||||||
EventWrapper& _timeEvent;
|
EventWrapper& _timeEvent;
|
||||||
CriticalSectionWrapper* _critSec;
|
CriticalSectionWrapper* _critSec;
|
||||||
WebRtc_Word64 _writtenVideoFramesCounter;
|
int64_t _writtenVideoFramesCounter;
|
||||||
WebRtc_Word64 _writtenAudioMS;
|
int64_t _writtenAudioMS;
|
||||||
WebRtc_Word64 _writtenVideoMS;
|
int64_t _writtenVideoMS;
|
||||||
};
|
};
|
||||||
#endif // WEBRTC_MODULE_UTILITY_VIDEO
|
#endif // WEBRTC_MODULE_UTILITY_VIDEO
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -42,7 +42,7 @@ ProcessThreadImpl::~ProcessThreadImpl()
|
|||||||
WEBRTC_TRACE(kTraceMemory, kTraceUtility, -1, "%s deleted", __FUNCTION__);
|
WEBRTC_TRACE(kTraceMemory, kTraceUtility, -1, "%s deleted", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 ProcessThreadImpl::Start()
|
int32_t ProcessThreadImpl::Start()
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock(_critSectModules);
|
CriticalSectionScoped lock(_critSectModules);
|
||||||
if(_thread)
|
if(_thread)
|
||||||
@ -52,7 +52,7 @@ WebRtc_Word32 ProcessThreadImpl::Start()
|
|||||||
_thread = ThreadWrapper::CreateThread(Run, this, kNormalPriority,
|
_thread = ThreadWrapper::CreateThread(Run, this, kNormalPriority,
|
||||||
"ProcessThread");
|
"ProcessThread");
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
WebRtc_Word32 retVal = _thread->Start(id);
|
int32_t retVal = _thread->Start(id);
|
||||||
if(retVal >= 0)
|
if(retVal >= 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -62,7 +62,7 @@ WebRtc_Word32 ProcessThreadImpl::Start()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 ProcessThreadImpl::Stop()
|
int32_t ProcessThreadImpl::Stop()
|
||||||
{
|
{
|
||||||
_critSectModules->Enter();
|
_critSectModules->Enter();
|
||||||
if(_thread)
|
if(_thread)
|
||||||
@ -87,13 +87,13 @@ WebRtc_Word32 ProcessThreadImpl::Stop()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 ProcessThreadImpl::RegisterModule(const Module* module)
|
int32_t ProcessThreadImpl::RegisterModule(const Module* module)
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock(_critSectModules);
|
CriticalSectionScoped lock(_critSectModules);
|
||||||
|
|
||||||
// Only allow module to be registered once.
|
// Only allow module to be registered once.
|
||||||
ListItem* item = _modules.First();
|
ListItem* item = _modules.First();
|
||||||
for(WebRtc_UWord32 i = 0; i < _modules.GetSize() && item; i++)
|
for(uint32_t i = 0; i < _modules.GetSize() && item; i++)
|
||||||
{
|
{
|
||||||
if(module == item->GetItem())
|
if(module == item->GetItem())
|
||||||
{
|
{
|
||||||
@ -113,12 +113,12 @@ WebRtc_Word32 ProcessThreadImpl::RegisterModule(const Module* module)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 ProcessThreadImpl::DeRegisterModule(const Module* module)
|
int32_t ProcessThreadImpl::DeRegisterModule(const Module* module)
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock(_critSectModules);
|
CriticalSectionScoped lock(_critSectModules);
|
||||||
|
|
||||||
ListItem* item = _modules.First();
|
ListItem* item = _modules.First();
|
||||||
for(WebRtc_UWord32 i = 0; i < _modules.GetSize() && item; i++)
|
for(uint32_t i = 0; i < _modules.GetSize() && item; i++)
|
||||||
{
|
{
|
||||||
if(module == item->GetItem())
|
if(module == item->GetItem())
|
||||||
{
|
{
|
||||||
@ -142,13 +142,13 @@ bool ProcessThreadImpl::Process()
|
|||||||
{
|
{
|
||||||
// Wait for the module that should be called next, but don't block thread
|
// Wait for the module that should be called next, but don't block thread
|
||||||
// longer than 100 ms.
|
// longer than 100 ms.
|
||||||
WebRtc_Word32 minTimeToNext = 100;
|
int32_t minTimeToNext = 100;
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock(_critSectModules);
|
CriticalSectionScoped lock(_critSectModules);
|
||||||
ListItem* item = _modules.First();
|
ListItem* item = _modules.First();
|
||||||
for(WebRtc_UWord32 i = 0; i < _modules.GetSize() && item; i++)
|
for(uint32_t i = 0; i < _modules.GetSize() && item; i++)
|
||||||
{
|
{
|
||||||
WebRtc_Word32 timeToNext =
|
int32_t timeToNext =
|
||||||
static_cast<Module*>(item->GetItem())->TimeUntilNextProcess();
|
static_cast<Module*>(item->GetItem())->TimeUntilNextProcess();
|
||||||
if(minTimeToNext > timeToNext)
|
if(minTimeToNext > timeToNext)
|
||||||
{
|
{
|
||||||
@ -173,9 +173,9 @@ bool ProcessThreadImpl::Process()
|
|||||||
{
|
{
|
||||||
CriticalSectionScoped lock(_critSectModules);
|
CriticalSectionScoped lock(_critSectModules);
|
||||||
ListItem* item = _modules.First();
|
ListItem* item = _modules.First();
|
||||||
for(WebRtc_UWord32 i = 0; i < _modules.GetSize() && item; i++)
|
for(uint32_t i = 0; i < _modules.GetSize() && item; i++)
|
||||||
{
|
{
|
||||||
WebRtc_Word32 timeToNext =
|
int32_t timeToNext =
|
||||||
static_cast<Module*>(item->GetItem())->TimeUntilNextProcess();
|
static_cast<Module*>(item->GetItem())->TimeUntilNextProcess();
|
||||||
if(timeToNext < 1)
|
if(timeToNext < 1)
|
||||||
{
|
{
|
||||||
|
@ -25,11 +25,11 @@ public:
|
|||||||
ProcessThreadImpl();
|
ProcessThreadImpl();
|
||||||
virtual ~ProcessThreadImpl();
|
virtual ~ProcessThreadImpl();
|
||||||
|
|
||||||
virtual WebRtc_Word32 Start();
|
virtual int32_t Start();
|
||||||
virtual WebRtc_Word32 Stop();
|
virtual int32_t Stop();
|
||||||
|
|
||||||
virtual WebRtc_Word32 RegisterModule(const Module* module);
|
virtual int32_t RegisterModule(const Module* module);
|
||||||
virtual WebRtc_Word32 DeRegisterModule(const Module* module);
|
virtual int32_t DeRegisterModule(const Module* module);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static bool Run(void* obj);
|
static bool Run(void* obj);
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
const char RTPFILE_VERSION[] = "1.0";
|
const char RTPFILE_VERSION[] = "1.0";
|
||||||
const WebRtc_UWord32 MAX_UWORD32 = 0xffffffff;
|
const uint32_t MAX_UWORD32 = 0xffffffff;
|
||||||
|
|
||||||
// This stucture is specified in the rtpdump documentation.
|
// This stucture is specified in the rtpdump documentation.
|
||||||
// This struct corresponds to RD_packet_t in
|
// This struct corresponds to RD_packet_t in
|
||||||
@ -49,11 +49,11 @@ typedef struct
|
|||||||
{
|
{
|
||||||
// Length of packet, including this header (may be smaller than plen if not
|
// Length of packet, including this header (may be smaller than plen if not
|
||||||
// whole packet recorded).
|
// whole packet recorded).
|
||||||
WebRtc_UWord16 length;
|
uint16_t length;
|
||||||
// Actual header+payload length for RTP, 0 for RTCP.
|
// Actual header+payload length for RTP, 0 for RTCP.
|
||||||
WebRtc_UWord16 plen;
|
uint16_t plen;
|
||||||
// Milliseconds since the start of recording.
|
// Milliseconds since the start of recording.
|
||||||
WebRtc_UWord32 offset;
|
uint32_t offset;
|
||||||
} rtpDumpPktHdr_t;
|
} rtpDumpPktHdr_t;
|
||||||
|
|
||||||
RtpDump* RtpDump::CreateRtpDump()
|
RtpDump* RtpDump::CreateRtpDump()
|
||||||
@ -87,7 +87,7 @@ RtpDumpImpl::~RtpDumpImpl()
|
|||||||
WEBRTC_TRACE(kTraceMemory, kTraceUtility, -1, "%s deleted", __FUNCTION__);
|
WEBRTC_TRACE(kTraceMemory, kTraceUtility, -1, "%s deleted", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 RtpDumpImpl::Start(const char* fileNameUTF8)
|
int32_t RtpDumpImpl::Start(const char* fileNameUTF8)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fileNameUTF8 == NULL)
|
if (fileNameUTF8 == NULL)
|
||||||
@ -136,7 +136,7 @@ WebRtc_Word32 RtpDumpImpl::Start(const char* fileNameUTF8)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 RtpDumpImpl::Stop()
|
int32_t RtpDumpImpl::Stop()
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock(_critSect);
|
CriticalSectionScoped lock(_critSect);
|
||||||
_file.Flush();
|
_file.Flush();
|
||||||
@ -150,8 +150,7 @@ bool RtpDumpImpl::IsActive() const
|
|||||||
return _file.Open();
|
return _file.Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 RtpDumpImpl::DumpPacket(const WebRtc_UWord8* packet,
|
int32_t RtpDumpImpl::DumpPacket(const uint8_t* packet, uint16_t packetLength)
|
||||||
WebRtc_UWord16 packetLength)
|
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock(_critSect);
|
CriticalSectionScoped lock(_critSect);
|
||||||
if (!IsActive())
|
if (!IsActive())
|
||||||
@ -174,7 +173,7 @@ WebRtc_Word32 RtpDumpImpl::DumpPacket(const WebRtc_UWord8* packet,
|
|||||||
bool isRTCP = RTCP(packet);
|
bool isRTCP = RTCP(packet);
|
||||||
|
|
||||||
rtpDumpPktHdr_t hdr;
|
rtpDumpPktHdr_t hdr;
|
||||||
WebRtc_UWord32 offset;
|
uint32_t offset;
|
||||||
|
|
||||||
// Offset is relative to when recording was started.
|
// Offset is relative to when recording was started.
|
||||||
offset = GetTimeInMS();
|
offset = GetTimeInMS();
|
||||||
@ -187,14 +186,14 @@ WebRtc_Word32 RtpDumpImpl::DumpPacket(const WebRtc_UWord8* packet,
|
|||||||
}
|
}
|
||||||
hdr.offset = RtpDumpHtonl(offset);
|
hdr.offset = RtpDumpHtonl(offset);
|
||||||
|
|
||||||
hdr.length = RtpDumpHtons((WebRtc_UWord16)(packetLength + sizeof(hdr)));
|
hdr.length = RtpDumpHtons((uint16_t)(packetLength + sizeof(hdr)));
|
||||||
if (isRTCP)
|
if (isRTCP)
|
||||||
{
|
{
|
||||||
hdr.plen = 0;
|
hdr.plen = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hdr.plen = RtpDumpHtons((WebRtc_UWord16)packetLength);
|
hdr.plen = RtpDumpHtons((uint16_t)packetLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_file.Write(&hdr, sizeof(hdr)))
|
if (!_file.Write(&hdr, sizeof(hdr)))
|
||||||
@ -213,9 +212,9 @@ WebRtc_Word32 RtpDumpImpl::DumpPacket(const WebRtc_UWord8* packet,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RtpDumpImpl::RTCP(const WebRtc_UWord8* packet) const
|
bool RtpDumpImpl::RTCP(const uint8_t* packet) const
|
||||||
{
|
{
|
||||||
const WebRtc_UWord8 payloadType = packet[1];
|
const uint8_t payloadType = packet[1];
|
||||||
bool is_rtcp = false;
|
bool is_rtcp = false;
|
||||||
|
|
||||||
switch(payloadType)
|
switch(payloadType)
|
||||||
@ -234,7 +233,7 @@ bool RtpDumpImpl::RTCP(const WebRtc_UWord8* packet) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO (hellner): why is TickUtil not used here?
|
// TODO (hellner): why is TickUtil not used here?
|
||||||
inline WebRtc_UWord32 RtpDumpImpl::GetTimeInMS() const
|
inline uint32_t RtpDumpImpl::GetTimeInMS() const
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return timeGetTime();
|
return timeGetTime();
|
||||||
@ -253,7 +252,7 @@ inline WebRtc_UWord32 RtpDumpImpl::GetTimeInMS() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WebRtc_UWord32 RtpDumpImpl::RtpDumpHtonl(WebRtc_UWord32 x) const
|
inline uint32_t RtpDumpImpl::RtpDumpHtonl(uint32_t x) const
|
||||||
{
|
{
|
||||||
#if defined(WEBRTC_BIG_ENDIAN)
|
#if defined(WEBRTC_BIG_ENDIAN)
|
||||||
return x;
|
return x;
|
||||||
@ -267,7 +266,7 @@ inline WebRtc_UWord32 RtpDumpImpl::RtpDumpHtonl(WebRtc_UWord32 x) const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WebRtc_UWord16 RtpDumpImpl::RtpDumpHtons(WebRtc_UWord16 x) const
|
inline uint16_t RtpDumpImpl::RtpDumpHtons(uint16_t x) const
|
||||||
{
|
{
|
||||||
#if defined(WEBRTC_BIG_ENDIAN)
|
#if defined(WEBRTC_BIG_ENDIAN)
|
||||||
return x;
|
return x;
|
||||||
|
@ -22,28 +22,27 @@ public:
|
|||||||
RtpDumpImpl();
|
RtpDumpImpl();
|
||||||
virtual ~RtpDumpImpl();
|
virtual ~RtpDumpImpl();
|
||||||
|
|
||||||
virtual WebRtc_Word32 Start(const char* fileNameUTF8);
|
virtual int32_t Start(const char* fileNameUTF8);
|
||||||
virtual WebRtc_Word32 Stop();
|
virtual int32_t Stop();
|
||||||
virtual bool IsActive() const;
|
virtual bool IsActive() const;
|
||||||
virtual WebRtc_Word32 DumpPacket(const WebRtc_UWord8* packet,
|
virtual int32_t DumpPacket(const uint8_t* packet, uint16_t packetLength);
|
||||||
WebRtc_UWord16 packetLength);
|
|
||||||
private:
|
private:
|
||||||
// Return the system time in ms.
|
// Return the system time in ms.
|
||||||
inline WebRtc_UWord32 GetTimeInMS() const;
|
inline uint32_t GetTimeInMS() const;
|
||||||
// Return x in network byte order (big endian).
|
// Return x in network byte order (big endian).
|
||||||
inline WebRtc_UWord32 RtpDumpHtonl(WebRtc_UWord32 x) const;
|
inline uint32_t RtpDumpHtonl(uint32_t x) const;
|
||||||
// Return x in network byte order (big endian).
|
// Return x in network byte order (big endian).
|
||||||
inline WebRtc_UWord16 RtpDumpHtons(WebRtc_UWord16 x) const;
|
inline uint16_t RtpDumpHtons(uint16_t x) const;
|
||||||
|
|
||||||
// Return true if the packet starts with a valid RTCP header.
|
// Return true if the packet starts with a valid RTCP header.
|
||||||
// Note: See ModuleRTPUtility::RTPHeaderParser::RTCP() for details on how
|
// Note: See ModuleRTPUtility::RTPHeaderParser::RTCP() for details on how
|
||||||
// to determine if the packet is an RTCP packet.
|
// to determine if the packet is an RTCP packet.
|
||||||
bool RTCP(const WebRtc_UWord8* packet) const;
|
bool RTCP(const uint8_t* packet) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CriticalSectionWrapper* _critSect;
|
CriticalSectionWrapper* _critSect;
|
||||||
FileWrapper& _file;
|
FileWrapper& _file;
|
||||||
WebRtc_UWord32 _startTime;
|
uint32_t _startTime;
|
||||||
};
|
};
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
#endif // WEBRTC_MODULES_UTILITY_SOURCE_RTP_DUMP_IMPL_H_
|
#endif // WEBRTC_MODULES_UTILITY_SOURCE_RTP_DUMP_IMPL_H_
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "video_coder.h"
|
#include "video_coder.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
VideoCoder::VideoCoder(WebRtc_UWord32 instanceID)
|
VideoCoder::VideoCoder(uint32_t instanceID)
|
||||||
: _vcm(VideoCodingModule::Create(instanceID)),
|
: _vcm(VideoCodingModule::Create(instanceID)),
|
||||||
_decodedVideo(0)
|
_decodedVideo(0)
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ VideoCoder::~VideoCoder()
|
|||||||
VideoCodingModule::Destroy(_vcm);
|
VideoCodingModule::Destroy(_vcm);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoCoder::ResetDecoder()
|
int32_t VideoCoder::ResetDecoder()
|
||||||
{
|
{
|
||||||
_vcm->ResetDecoder();
|
_vcm->ResetDecoder();
|
||||||
|
|
||||||
@ -41,9 +41,9 @@ WebRtc_Word32 VideoCoder::ResetDecoder()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoCoder::SetEncodeCodec(VideoCodec& videoCodecInst,
|
int32_t VideoCoder::SetEncodeCodec(VideoCodec& videoCodecInst,
|
||||||
WebRtc_UWord32 numberOfCores,
|
uint32_t numberOfCores,
|
||||||
WebRtc_UWord32 maxPayloadSize)
|
uint32_t maxPayloadSize)
|
||||||
{
|
{
|
||||||
if(_vcm->RegisterSendCodec(&videoCodecInst, numberOfCores,
|
if(_vcm->RegisterSendCodec(&videoCodecInst, numberOfCores,
|
||||||
maxPayloadSize) != VCM_OK)
|
maxPayloadSize) != VCM_OK)
|
||||||
@ -54,12 +54,12 @@ WebRtc_Word32 VideoCoder::SetEncodeCodec(VideoCodec& videoCodecInst,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WebRtc_Word32 VideoCoder::SetDecodeCodec(VideoCodec& videoCodecInst,
|
int32_t VideoCoder::SetDecodeCodec(VideoCodec& videoCodecInst,
|
||||||
WebRtc_Word32 numberOfCores)
|
int32_t numberOfCores)
|
||||||
{
|
{
|
||||||
if (videoCodecInst.plType == 0)
|
if (videoCodecInst.plType == 0)
|
||||||
{
|
{
|
||||||
WebRtc_Word8 plType = DefaultPayloadType(videoCodecInst.plName);
|
int8_t plType = DefaultPayloadType(videoCodecInst.plName);
|
||||||
if (plType == -1)
|
if (plType == -1)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -74,7 +74,7 @@ WebRtc_Word32 VideoCoder::SetDecodeCodec(VideoCodec& videoCodecInst,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoCoder::Decode(I420VideoFrame& decodedVideo,
|
int32_t VideoCoder::Decode(I420VideoFrame& decodedVideo,
|
||||||
const EncodedVideoData& encodedData)
|
const EncodedVideoData& encodedData)
|
||||||
{
|
{
|
||||||
decodedVideo.ResetSize();
|
decodedVideo.ResetSize();
|
||||||
@ -92,7 +92,7 @@ WebRtc_Word32 VideoCoder::Decode(I420VideoFrame& decodedVideo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WebRtc_Word32 VideoCoder::Encode(const I420VideoFrame& videoFrame,
|
int32_t VideoCoder::Encode(const I420VideoFrame& videoFrame,
|
||||||
EncodedVideoData& videoEncodedData)
|
EncodedVideoData& videoEncodedData)
|
||||||
{
|
{
|
||||||
// The AddVideoFrame(..) call will (indirectly) call SendData(). Store a
|
// The AddVideoFrame(..) call will (indirectly) call SendData(). Store a
|
||||||
@ -106,11 +106,11 @@ WebRtc_Word32 VideoCoder::Encode(const I420VideoFrame& videoFrame,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word8 VideoCoder::DefaultPayloadType(const char* plName)
|
int8_t VideoCoder::DefaultPayloadType(const char* plName)
|
||||||
{
|
{
|
||||||
VideoCodec tmpCodec;
|
VideoCodec tmpCodec;
|
||||||
WebRtc_Word32 numberOfCodecs = _vcm->NumberOfCodecs();
|
int32_t numberOfCodecs = _vcm->NumberOfCodecs();
|
||||||
for (WebRtc_UWord8 i = 0; i < numberOfCodecs; i++)
|
for (uint8_t i = 0; i < numberOfCodecs; i++)
|
||||||
{
|
{
|
||||||
_vcm->Codec(i, &tmpCodec);
|
_vcm->Codec(i, &tmpCodec);
|
||||||
if(strncmp(tmpCodec.plName, plName, kPayloadNameSize) == 0)
|
if(strncmp(tmpCodec.plName, plName, kPayloadNameSize) == 0)
|
||||||
@ -121,18 +121,18 @@ WebRtc_Word8 VideoCoder::DefaultPayloadType(const char* plName)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoCoder::FrameToRender(I420VideoFrame& videoFrame)
|
int32_t VideoCoder::FrameToRender(I420VideoFrame& videoFrame)
|
||||||
{
|
{
|
||||||
return _decodedVideo->CopyFrame(videoFrame);
|
return _decodedVideo->CopyFrame(videoFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoCoder::SendData(
|
int32_t VideoCoder::SendData(
|
||||||
const FrameType frameType,
|
const FrameType frameType,
|
||||||
const WebRtc_UWord8 payloadType,
|
const uint8_t payloadType,
|
||||||
const WebRtc_UWord32 timeStamp,
|
const uint32_t timeStamp,
|
||||||
int64_t capture_time_ms,
|
int64_t capture_time_ms,
|
||||||
const WebRtc_UWord8* payloadData,
|
const uint8_t* payloadData,
|
||||||
WebRtc_UWord32 payloadSize,
|
uint32_t payloadSize,
|
||||||
const RTPFragmentationHeader& fragmentationHeader,
|
const RTPFragmentationHeader& fragmentationHeader,
|
||||||
const RTPVideoHeader* /*rtpVideoHdr*/)
|
const RTPVideoHeader* /*rtpVideoHdr*/)
|
||||||
{
|
{
|
||||||
@ -144,7 +144,7 @@ WebRtc_Word32 VideoCoder::SendData(
|
|||||||
_videoEncodedData->timeStamp = timeStamp;
|
_videoEncodedData->timeStamp = timeStamp;
|
||||||
_videoEncodedData->fragmentationHeader.CopyFrom(fragmentationHeader);
|
_videoEncodedData->fragmentationHeader.CopyFrom(fragmentationHeader);
|
||||||
memcpy(_videoEncodedData->payloadData, payloadData,
|
memcpy(_videoEncodedData->payloadData, payloadData,
|
||||||
sizeof(WebRtc_UWord8) * payloadSize);
|
sizeof(uint8_t) * payloadSize);
|
||||||
_videoEncodedData->payloadSize = payloadSize;
|
_videoEncodedData->payloadSize = payloadSize;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -20,43 +20,42 @@ namespace webrtc {
|
|||||||
class VideoCoder : public VCMPacketizationCallback, public VCMReceiveCallback
|
class VideoCoder : public VCMPacketizationCallback, public VCMReceiveCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VideoCoder(WebRtc_UWord32 instanceID);
|
VideoCoder(uint32_t instanceID);
|
||||||
~VideoCoder();
|
~VideoCoder();
|
||||||
|
|
||||||
WebRtc_Word32 ResetDecoder();
|
int32_t ResetDecoder();
|
||||||
|
|
||||||
WebRtc_Word32 SetEncodeCodec(VideoCodec& videoCodecInst,
|
int32_t SetEncodeCodec(VideoCodec& videoCodecInst,
|
||||||
WebRtc_UWord32 numberOfCores,
|
uint32_t numberOfCores,
|
||||||
WebRtc_UWord32 maxPayloadSize);
|
uint32_t maxPayloadSize);
|
||||||
|
|
||||||
|
|
||||||
// Select the codec that should be used for decoding. videoCodecInst.plType
|
// Select the codec that should be used for decoding. videoCodecInst.plType
|
||||||
// will be set to the codec's default payload type.
|
// will be set to the codec's default payload type.
|
||||||
WebRtc_Word32 SetDecodeCodec(VideoCodec& videoCodecInst,
|
int32_t SetDecodeCodec(VideoCodec& videoCodecInst, int32_t numberOfCores);
|
||||||
WebRtc_Word32 numberOfCores);
|
|
||||||
|
|
||||||
WebRtc_Word32 Decode(I420VideoFrame& decodedVideo,
|
int32_t Decode(I420VideoFrame& decodedVideo,
|
||||||
const EncodedVideoData& encodedData);
|
const EncodedVideoData& encodedData);
|
||||||
|
|
||||||
WebRtc_Word32 Encode(const I420VideoFrame& videoFrame,
|
int32_t Encode(const I420VideoFrame& videoFrame,
|
||||||
EncodedVideoData& videoEncodedData);
|
EncodedVideoData& videoEncodedData);
|
||||||
|
|
||||||
WebRtc_Word8 DefaultPayloadType(const char* plName);
|
int8_t DefaultPayloadType(const char* plName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// VCMReceiveCallback function.
|
// VCMReceiveCallback function.
|
||||||
// Note: called by VideoCodingModule when decoding finished.
|
// Note: called by VideoCodingModule when decoding finished.
|
||||||
WebRtc_Word32 FrameToRender(I420VideoFrame& videoFrame);
|
int32_t FrameToRender(I420VideoFrame& videoFrame);
|
||||||
|
|
||||||
// VCMPacketizationCallback function.
|
// VCMPacketizationCallback function.
|
||||||
// Note: called by VideoCodingModule when encoding finished.
|
// Note: called by VideoCodingModule when encoding finished.
|
||||||
WebRtc_Word32 SendData(
|
int32_t SendData(
|
||||||
FrameType /*frameType*/,
|
FrameType /*frameType*/,
|
||||||
WebRtc_UWord8 /*payloadType*/,
|
uint8_t /*payloadType*/,
|
||||||
WebRtc_UWord32 /*timeStamp*/,
|
uint32_t /*timeStamp*/,
|
||||||
int64_t capture_time_ms,
|
int64_t capture_time_ms,
|
||||||
const WebRtc_UWord8* payloadData,
|
const uint8_t* payloadData,
|
||||||
WebRtc_UWord32 payloadSize,
|
uint32_t payloadSize,
|
||||||
const RTPFragmentationHeader& /* fragmentationHeader*/,
|
const RTPFragmentationHeader& /* fragmentationHeader*/,
|
||||||
const RTPVideoHeader* rtpTypeHdr);
|
const RTPVideoHeader* rtpTypeHdr);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ VideoFramesQueue::~VideoFramesQueue() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoFramesQueue::AddFrame(const I420VideoFrame& newFrame) {
|
int32_t VideoFramesQueue::AddFrame(const I420VideoFrame& newFrame) {
|
||||||
I420VideoFrame* ptrFrameToAdd = NULL;
|
I420VideoFrame* ptrFrameToAdd = NULL;
|
||||||
// Try to re-use a VideoFrame. Only allocate new memory if it is necessary.
|
// Try to re-use a VideoFrame. Only allocate new memory if it is necessary.
|
||||||
if (!_emptyFrames.Empty()) {
|
if (!_emptyFrames.Empty()) {
|
||||||
@ -112,7 +112,7 @@ I420VideoFrame* VideoFramesQueue::FrameToRecord() {
|
|||||||
return ptrRenderFrame;
|
return ptrRenderFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoFramesQueue::ReturnFrame(I420VideoFrame* ptrOldFrame) {
|
int32_t VideoFramesQueue::ReturnFrame(I420VideoFrame* ptrOldFrame) {
|
||||||
ptrOldFrame->set_timestamp(0);
|
ptrOldFrame->set_timestamp(0);
|
||||||
ptrOldFrame->set_width(0);
|
ptrOldFrame->set_width(0);
|
||||||
ptrOldFrame->set_height(0);
|
ptrOldFrame->set_height(0);
|
||||||
@ -122,7 +122,7 @@ WebRtc_Word32 VideoFramesQueue::ReturnFrame(I420VideoFrame* ptrOldFrame) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoFramesQueue::SetRenderDelay(WebRtc_UWord32 renderDelay) {
|
int32_t VideoFramesQueue::SetRenderDelay(uint32_t renderDelay) {
|
||||||
_renderDelayMs = renderDelay;
|
_renderDelayMs = renderDelay;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ class VideoFramesQueue {
|
|||||||
~VideoFramesQueue();
|
~VideoFramesQueue();
|
||||||
|
|
||||||
// Put newFrame (last) in the queue.
|
// Put newFrame (last) in the queue.
|
||||||
WebRtc_Word32 AddFrame(const I420VideoFrame& newFrame);
|
int32_t AddFrame(const I420VideoFrame& newFrame);
|
||||||
|
|
||||||
// Return the most current frame. I.e. the frame with the highest
|
// Return the most current frame. I.e. the frame with the highest
|
||||||
// VideoFrame::RenderTimeMs() that is lower than
|
// VideoFrame::RenderTimeMs() that is lower than
|
||||||
@ -34,12 +34,12 @@ class VideoFramesQueue {
|
|||||||
I420VideoFrame* FrameToRecord();
|
I420VideoFrame* FrameToRecord();
|
||||||
|
|
||||||
// Set the render delay estimate to renderDelay ms.
|
// Set the render delay estimate to renderDelay ms.
|
||||||
WebRtc_Word32 SetRenderDelay(WebRtc_UWord32 renderDelay);
|
int32_t SetRenderDelay(uint32_t renderDelay);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Make ptrOldFrame available for re-use. I.e. put it in the empty frames
|
// Make ptrOldFrame available for re-use. I.e. put it in the empty frames
|
||||||
// queue.
|
// queue.
|
||||||
WebRtc_Word32 ReturnFrame(I420VideoFrame* ptrOldFrame);
|
int32_t ReturnFrame(I420VideoFrame* ptrOldFrame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Don't allow the buffer to expand beyond KMaxNumberOfFrames VideoFrames.
|
// Don't allow the buffer to expand beyond KMaxNumberOfFrames VideoFrames.
|
||||||
@ -54,7 +54,7 @@ class VideoFramesQueue {
|
|||||||
ListWrapper _emptyFrames;
|
ListWrapper _emptyFrames;
|
||||||
|
|
||||||
// Estimated render delay.
|
// Estimated render delay.
|
||||||
WebRtc_UWord32 _renderDelayMs;
|
uint32_t _renderDelayMs;
|
||||||
};
|
};
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
#endif // WEBRTC_MODULE_UTILITY_VIDEO
|
#endif // WEBRTC_MODULE_UTILITY_VIDEO
|
||||||
|
@ -38,29 +38,29 @@ bool notify = false, playing = false, recording = false;
|
|||||||
class MyFileModuleCallback : public FileCallback
|
class MyFileModuleCallback : public FileCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void PlayNotification( const WebRtc_Word32 id,
|
virtual void PlayNotification( const int32_t id,
|
||||||
const WebRtc_UWord32 durationMs )
|
const uint32_t durationMs )
|
||||||
{
|
{
|
||||||
printf("\tReceived PlayNotification from module %ld, durationMs = %ld\n",
|
printf("\tReceived PlayNotification from module %ld, durationMs = %ld\n",
|
||||||
id, durationMs);
|
id, durationMs);
|
||||||
notify = true;
|
notify = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void RecordNotification( const WebRtc_Word32 id,
|
virtual void RecordNotification( const int32_t id,
|
||||||
const WebRtc_UWord32 durationMs )
|
const uint32_t durationMs )
|
||||||
{
|
{
|
||||||
printf("\tReceived RecordNotification from module %ld, durationMs = %ld\n",
|
printf("\tReceived RecordNotification from module %ld, durationMs = %ld\n",
|
||||||
id, durationMs);
|
id, durationMs);
|
||||||
notify = true;
|
notify = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void PlayFileEnded(const WebRtc_Word32 id)
|
virtual void PlayFileEnded(const int32_t id)
|
||||||
{
|
{
|
||||||
printf("\tReceived PlayFileEnded notification from module %ld.\n", id);
|
printf("\tReceived PlayFileEnded notification from module %ld.\n", id);
|
||||||
playing = false;
|
playing = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void RecordFileEnded(const WebRtc_Word32 id)
|
virtual void RecordFileEnded(const int32_t id)
|
||||||
{
|
{
|
||||||
printf("\tReceived RecordFileEnded notification from module %ld.\n", id);
|
printf("\tReceived RecordFileEnded notification from module %ld.\n", id);
|
||||||
recording = false;
|
recording = false;
|
||||||
@ -151,14 +151,14 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
::Sleep(10);
|
::Sleep(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WebRtc_UWord32 decodedDataLengthInSamples;
|
uint32_t decodedDataLengthInSamples;
|
||||||
if( 0 != filePlayer.Get10msAudioFromFile( audioFrame.data_, decodedDataLengthInSamples, audioCodec.plfreq))
|
if( 0 != filePlayer.Get10msAudioFromFile( audioFrame.data_, decodedDataLengthInSamples, audioCodec.plfreq))
|
||||||
{
|
{
|
||||||
audioNotDone = false;
|
audioNotDone = false;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
audioFrame.sample_rate_hz_ = filePlayer.Frequency();
|
audioFrame.sample_rate_hz_ = filePlayer.Frequency();
|
||||||
audioFrame.samples_per_channel_ = (WebRtc_UWord16)decodedDataLengthInSamples;
|
audioFrame.samples_per_channel_ = (uint16_t)decodedDataLengthInSamples;
|
||||||
fileRecorder.RecordAudioToFile(audioFrame, &TickTime::Now());
|
fileRecorder.RecordAudioToFile(audioFrame, &TickTime::Now());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
|
|
||||||
assert(fileRecorder.IsRecording());
|
assert(fileRecorder.IsRecording());
|
||||||
|
|
||||||
const WebRtc_UWord32 KVideoWriteSize = static_cast< WebRtc_UWord32>( (videoCodec.width * videoCodec.height * 3) / 2);
|
const uint32_t KVideoWriteSize = static_cast< uint32_t>( (videoCodec.width * videoCodec.height * 3) / 2);
|
||||||
webrtc::VideoFrame videoFrame;
|
webrtc::VideoFrame videoFrame;
|
||||||
|
|
||||||
// 10 ms
|
// 10 ms
|
||||||
@ -339,7 +339,7 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_UWord32 decodedDataLengthInSamples;
|
uint32_t decodedDataLengthInSamples;
|
||||||
if( 0 != filePlayer.Get10msAudioFromFile( audioFrame.data_, decodedDataLengthInSamples, audioCodec.plfreq))
|
if( 0 != filePlayer.Get10msAudioFromFile( audioFrame.data_, decodedDataLengthInSamples, audioCodec.plfreq))
|
||||||
{
|
{
|
||||||
audioNotDone = false;
|
audioNotDone = false;
|
||||||
@ -348,7 +348,7 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
{
|
{
|
||||||
::Sleep(5);
|
::Sleep(5);
|
||||||
audioFrame.sample_rate_hz_ = filePlayer.Frequency();
|
audioFrame.sample_rate_hz_ = filePlayer.Frequency();
|
||||||
audioFrame.samples_per_channel_ = (WebRtc_UWord16)decodedDataLengthInSamples;
|
audioFrame.samples_per_channel_ = (uint16_t)decodedDataLengthInSamples;
|
||||||
assert(0 == fileRecorder.RecordAudioToFile(audioFrame));
|
assert(0 == fileRecorder.RecordAudioToFile(audioFrame));
|
||||||
|
|
||||||
audioFrameCount++;
|
audioFrameCount++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user