2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-04-12 11:02:38 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_TEST_RTPFILE_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_TEST_RTPFILE_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <queue>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
2018-03-23 14:53:54 +01:00
|
|
|
#include "rtc_base/synchronization/rw_lock_wrapper.h"
|
2013-10-02 21:44:33 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
class RTPStream {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~RTPStream() {}
|
|
|
|
|
|
|
|
|
|
virtual void Write(const uint8_t payloadType,
|
|
|
|
|
const uint32_t timeStamp,
|
|
|
|
|
const int16_t seqNo,
|
|
|
|
|
const uint8_t* payloadData,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
const size_t payloadSize,
|
|
|
|
|
uint32_t frequency) = 0;
|
2013-05-03 07:34:12 +00:00
|
|
|
|
|
|
|
|
// Returns the packet's payload size. Zero should be treated as an
|
|
|
|
|
// end-of-stream (in the case that EndOfFile() is true) or an error.
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
virtual size_t Read(WebRtcRTPHeader* rtpInfo,
|
|
|
|
|
uint8_t* payloadData,
|
|
|
|
|
size_t payloadSize,
|
|
|
|
|
uint32_t* offset) = 0;
|
2013-05-03 07:34:12 +00:00
|
|
|
virtual bool EndOfFile() const = 0;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void MakeRTPheader(uint8_t* rtpHeader,
|
|
|
|
|
uint8_t payloadType,
|
|
|
|
|
int16_t seqNo,
|
|
|
|
|
uint32_t timeStamp,
|
|
|
|
|
uint32_t ssrc);
|
|
|
|
|
|
|
|
|
|
void ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const uint8_t* rtpHeader);
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
class RTPPacket {
|
|
|
|
|
public:
|
|
|
|
|
RTPPacket(uint8_t payloadType,
|
|
|
|
|
uint32_t timeStamp,
|
|
|
|
|
int16_t seqNo,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
const uint8_t* payloadData,
|
|
|
|
|
size_t payloadSize,
|
2013-05-03 07:34:12 +00:00
|
|
|
uint32_t frequency);
|
|
|
|
|
|
|
|
|
|
~RTPPacket();
|
|
|
|
|
|
|
|
|
|
uint8_t payloadType;
|
|
|
|
|
uint32_t timeStamp;
|
|
|
|
|
int16_t seqNo;
|
|
|
|
|
uint8_t* payloadData;
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t payloadSize;
|
2013-05-03 07:34:12 +00:00
|
|
|
uint32_t frequency;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
class RTPBuffer : public RTPStream {
|
|
|
|
|
public:
|
|
|
|
|
RTPBuffer();
|
|
|
|
|
|
|
|
|
|
~RTPBuffer();
|
|
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void Write(const uint8_t payloadType,
|
|
|
|
|
const uint32_t timeStamp,
|
|
|
|
|
const int16_t seqNo,
|
|
|
|
|
const uint8_t* payloadData,
|
|
|
|
|
const size_t payloadSize,
|
|
|
|
|
uint32_t frequency) override;
|
2013-05-03 07:34:12 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
size_t Read(WebRtcRTPHeader* rtpInfo,
|
|
|
|
|
uint8_t* payloadData,
|
|
|
|
|
size_t payloadSize,
|
|
|
|
|
uint32_t* offset) override;
|
2013-05-03 07:34:12 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
bool EndOfFile() const override;
|
2013-05-03 07:34:12 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
RWLockWrapper* _queueRWLock;
|
|
|
|
|
std::queue<RTPPacket*> _rtpQueue;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
class RTPFile : public RTPStream {
|
|
|
|
|
public:
|
|
|
|
|
~RTPFile() {}
|
|
|
|
|
|
|
|
|
|
RTPFile() : _rtpFile(NULL), _rtpEOF(false) {}
|
|
|
|
|
|
|
|
|
|
void Open(const char* outFilename, const char* mode);
|
|
|
|
|
|
|
|
|
|
void Close();
|
|
|
|
|
|
|
|
|
|
void WriteHeader();
|
|
|
|
|
|
|
|
|
|
void ReadHeader();
|
|
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void Write(const uint8_t payloadType,
|
|
|
|
|
const uint32_t timeStamp,
|
|
|
|
|
const int16_t seqNo,
|
|
|
|
|
const uint8_t* payloadData,
|
|
|
|
|
const size_t payloadSize,
|
|
|
|
|
uint32_t frequency) override;
|
2013-05-03 07:34:12 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
size_t Read(WebRtcRTPHeader* rtpInfo,
|
|
|
|
|
uint8_t* payloadData,
|
|
|
|
|
size_t payloadSize,
|
|
|
|
|
uint32_t* offset) override;
|
2013-05-03 07:34:12 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
bool EndOfFile() const override { return _rtpEOF; }
|
2013-05-03 07:34:12 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
FILE* _rtpFile;
|
|
|
|
|
bool _rtpEOF;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
} // namespace webrtc
|
2013-10-02 21:44:33 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_TEST_RTPFILE_H_
|