整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
98
video/mediaserver/MPEGMuxer.h
Normal file
98
video/mediaserver/MPEGMuxer.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
#ifndef F9CED6CA_74FC_49C3_8D58_95A62F2EA1EC
|
||||
#define F9CED6CA_74FC_49C3_8D58_95A62F2EA1EC
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "../core/Muxer.h"
|
||||
#include "util/ClassAssistant.h"
|
||||
#include <sdk/include/sockutil.h>
|
||||
#include <media-server/libmpeg/mpeg-muxer.h>
|
||||
#include <media-server/libmpeg/mpeg-proto.h>
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* MACROS
|
||||
*******************************************************************************
|
||||
*/
|
||||
#define TRACE_VIDEO_FRAME_RATE (0)
|
||||
|
||||
namespace Video
|
||||
{
|
||||
namespace MediaServer
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class MPEGMuxer: public Core::Muxer
|
||||
{
|
||||
private:
|
||||
class Stream
|
||||
{
|
||||
public:
|
||||
using Ptr = Poco::SharedPtr<Stream>;
|
||||
|
||||
public:
|
||||
Stream(const std::string& name, int id, Core::PacketQueue::Ptr pQueue);
|
||||
~Stream();
|
||||
|
||||
public:
|
||||
bool operator<(const Stream& other);
|
||||
Core::PacketQueue::Ptr queue();
|
||||
Core::SerialCodeWatcher& serialCodeWatcher();
|
||||
|
||||
PROPERTY_DECLARE(Timeline, uint64_t, 0, public, public);
|
||||
READONLY_PROPERTY_DECLARE(name, std::string)
|
||||
READONLY_PROPERTY_DECLARE(id, int)
|
||||
|
||||
private:
|
||||
Core::PacketQueue::Ptr _pQueue;
|
||||
Core::SerialCodeWatcher _serialCodeWatcher;
|
||||
};
|
||||
|
||||
public:
|
||||
MPEGMuxer(const std::string& url);
|
||||
~MPEGMuxer();
|
||||
|
||||
protected:
|
||||
void connect() override;
|
||||
void mux() override;
|
||||
void disconnect() override;
|
||||
void flush();
|
||||
|
||||
const int getCodecID(Core::CodecID id);
|
||||
|
||||
private:
|
||||
socket_t _socket;
|
||||
struct sockaddr_in _destAddr;
|
||||
mpeg_muxer_t* _pMuxer;
|
||||
std::vector<Stream::Ptr> _streams;
|
||||
|
||||
uint8_t _buffer[1316];
|
||||
int _writeIndex;
|
||||
#if (TRACE_VIDEO_FRAME_RATE)
|
||||
int count = 0;
|
||||
uint64_t timeline = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
inline bool MPEGMuxer::Stream::operator<(const Stream& other)
|
||||
{
|
||||
return _Timeline < other._Timeline;
|
||||
}
|
||||
|
||||
inline Core::PacketQueue::Ptr MPEGMuxer::Stream::queue()
|
||||
{
|
||||
return _pQueue;
|
||||
}
|
||||
|
||||
inline Core::SerialCodeWatcher& MPEGMuxer::Stream::serialCodeWatcher()
|
||||
{
|
||||
return _serialCodeWatcher;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue