qt_rtmp_demo/media/RtmpPuller2.h

79 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#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 头部信息因为aac码流只会在首包发送
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;
};