-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathH264VideoFileStreamSource.h
More file actions
81 lines (69 loc) · 1.85 KB
/
H264VideoFileStreamSource.h
File metadata and controls
81 lines (69 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once
#include "streamSource.h"
#include "localFileReader.h"
#include "RTSP.h"
#include "RTP.h"
#include <mutex>
#include <vector>
#include <thread>
class H264VideoFileStreamSource:public streamSource
{
public:
H264VideoFileStreamSource(const char *file_name, LP_RTSP_session session);
~H264VideoFileStreamSource();
virtual int handTask(taskScheduleObj *task_obj);
protected:
virtual int startStream(taskScheduleObj *task_obj);
virtual int stopStream(taskScheduleObj *task_obj);
virtual int notify_stoped();
private:
H264VideoFileStreamSource(H264VideoFileStreamSource&);
//发送线程;
static void sendThread(void *lparam);
//发送一帧;
int send_frame();
//根据帧数据生成可以发送的帧,如果是TCP模式,后需加上TCP头;
int generate_sendable_frame(std::list<DataPacket> &frames, int frame_size);
//增长seq;
unsigned short incrementSeq();
//填充RTP_header到一个buffer里;
void fillRtpHeader2Buf(RTP_header &rtp_header, char *buf);
static const int s_base_frame_size=1024*1024;
void shutdown();
//读取sps,pps,分析宽高和fps;
void initStreamFile();
bool get_sps_pps();
bool anasys_sps_pps();
int get_frame();
int m_RTSP_socket_id;
localFileReader *m_file_reader;
char *m_tmp_buf_in;
int m_tmp_size;
char *m_sps;
int m_sps_len;
char *m_pps;
char *m_frame_data;
int m_frame_size;
int m_frame_container_size;
int m_pps_len;
int m_video_width;
int m_video_height;
int m_fps;
in_addr m_sock_addr;
socket_t m_rtp_socket;
socket_t m_rtcp_socket;
//264文件只有一个session;
LP_RTSP_session m_session;
unsigned int m_rtcp_ssrc;
unsigned short m_seq;
unsigned short m_seq_num;
unsigned int m_rtp_pkg_counts;
unsigned int m_rtp_data_size;
timeval m_rtcp_time;
volatile bool m_send_end;
std::mutex m_mutex_send;
std::thread m_thread_send;
std::vector<std::string> m_vectorRtspSendData;
std::mutex m_mutexRtspSend;
bool m_hasCalledDelete;
};