qt_rtmp_demo/media/RtmpPuller2.h

79 lines
1.4 KiB
C
Raw Normal View History

2023-11-12 16:13:24 +00:00
#pragma once
#ifdef __cplusplus
extern "C"{
#endif
extern "C" {
#include "librtmp\rtmp.h"
#include "librtmp\rtmp_sys.h"
#include "librtmp\amf.h"
}
#ifdef __cplusplus
}
#endif
#include <windows.h>
#include <string>
#include <thread>
#include <vector>
#include <mutex>
using namespace std;
#ifdef WIN32
#include <windows.h>
#pragma comment(lib,"WS2_32.lib")
#pragma comment(lib,"winmm.lib")
#endif
class RtmpPuller2
{
public:
class RtmpPullObserver {
public:
enum ObserverType {
Observer_Video = 0,
Observer_Audio = 1,
};
virtual void OnRtmpFrame(void * dat, uint32_t size) {};
ObserverType mObserverType;
};
enum CAP_STATUS {
CONNECTED = 0,
RUNNING = 1,
STOP = 2,
PAUSE = 3,
FAIL = 4,
NOSOURCE = 6,
};
RtmpPuller2();
~RtmpPuller2();
int StopPull();
int StartPull();
int PullData();
int SetObserver(RtmpPuller2::RtmpPullObserver *);
CAP_STATUS Status();
int ConnectServer(string url);
private:
std::thread *mThread;
RTMP *mRtmp;
string mUrl;
CAP_STATUS mStatus;
vector<RtmpPuller2::RtmpPullObserver*> mObserver;
mutex mMux;
uint8_t *mAccBuffer;
// adts ͷ<><CDB7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>Ϊaac<61><63><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD>
uint8_t ch0 = 0;
uint8_t ch1 = 0;
uint16_t config = 0;
uint16_t object_type = 0;
uint16_t sample_frequency_index = 0;
uint16_t channels = 0;
uint16_t frame_length_flag = 0;
uint16_t depend_on_core_coder = 0;
uint16_t extension_flag = 0;
};