资源简介
rtsp 流媒体服务器代码,实现了rtsp输出H264编码的视频流。VC可以编译,代码比较简单,做RTSP服务器功能的可以参考使用。
代码片段和文件信息
#include “stdafx.h“
#include “Rtp.h“
Rtp::Rtp(UINT mtu) :Udp(mtu)
{
m_SequenceNumber = 0;
}
Rtp::~Rtp()
{
}
int Rtp::Read(BYTE* pBuffer UINT16 bufferSize INT8* pPayloadType UINT16* pSequenceNumber INT32* pTimeStamp INT32* pSsrc UINT nTimeOut)
{
int iRead;
UINT8 payloadType;
UINT16 sequenceNumber;
INT32 timeStamp;
INT32 ssrc;
m_RtpPacket.ExtendBuffer(bufferSize+RTP_HEADER_SIZE);
m_RtpPacket.ClearData();
iRead = Udp::Read(m_RtpPacket.m_pBuffer m_RtpPacket.m_nBufferSize nTimeOut);
if (iRead < 12)
return -1;
if (!ParseRtpHeader(m_RtpPacket.m_pBuffer &payloadType &sequenceNumber &timeStamp &ssrc))
return -1;
m_RtpPacket.m_nDataSize = iRead;
memcpy(pBuffer m_RtpPacket.m_pBuffer + RTP_HEADER_SIZE iRead - RTP_HEADER_SIZE);
if (pPayloadType)
*pPayloadType = payloadType;
if (pSequenceNumber)
*pSequenceNumber = sequenceNumber;
if (pTimeStamp)
*pTimeStamp = timeStamp;
if (pSsrc)
*pSsrc = ssrc;
return iRead - RTP_HEADER_SIZE;
}
int Rtp::Write(PBYTE pBuffer UINT16 bufferSize INT8 payloadType INT32 timeStamp INT32 ssrc BOOL marker UINT nTimeOut)
{
int iWrite;
CreateRtpPacket(pBuffer bufferSize payloadType timeStamp ssrc marker);
iWrite = Udp::Write(m_RtpPacket.m_pBuffer m_RtpPacket.m_nDataSize nTimeOut);
if (iWrite < RTP_HEADER_SIZE)
return -1;
return iWrite - RTP_HEADER_SIZE;
}
void Rtp::CreateRtpPacket(PBYTE pData UINT16 dataSize UINT8 nPayloadType INT32 timeStamp INT32 nSSRC BOOL marker)
{
m_RtpPacket.ExtendBuffer(RTP_HEADER_SIZE + dataSize);
m_RtpPacket.ClearData();
m_RtpPacket.m_pBuffer[0] = 0x80;
m_RtpPacket.m_pBuffer[1] = (marker?0x80:0x00)|nPayloadType;
m_RtpPacket.m_pBuffer[2] = ( m_SequenceNumber >> 8 )&0xff;
m_RtpPacket.m_pBuffer[3] = m_SequenceNumber&0xff;
m_RtpPacket.m_pBuffer[4] = (BYTE)( timeStamp >> 24 )&0xff;
m_RtpPacket.m_pBuffer[5] = (BYTE)( timeStamp >> 16 )&0xff;
m_RtpPacket.m_pBuffer[6] = (BYTE)( timeStamp >> 8 )&0xff;
m_RtpPacket.m_pBuffer[7] = (BYTE)timeStamp&0xff;
m_RtpPacket.m_pBuffer[ 8] = ( nSSRC >> 24 )&0xff;
m_RtpPacket.m_pBuffer[ 9] = ( nSSRC >> 16 )&0xff;
m_RtpPacket.m_pBuffer[10] = ( nSSRC >> 8 )&0xff;
m_RtpPacket.m_pBuffer[11] = nSSRC&0xff;
m_SequenceNumber++;
m_RtpPacket.m_nDataSize = RTP_HEADER_SIZE;
m_RtpPacket.AppendData(pData dataSize);
}
BOOL Rtp::ParseRtpHeader(PBYTE pRtpHeader UINT8* pPayloadType UINT16* pSequenceNumber INT32* pTimeStamp INT32* pSsrc)
{
if (pRtpHeader[0] != 0x80)
return FALSE;
*pPayloadType = pRtpHeader[1];
*pSequenceNumber = ((WORD)pRtpHeader[2]) << 8 | pRtpHeader[3];
*pTimeStamp = (INT32)pRtpHeader[4] << 24 | (INT32)pRtpHeader[5] << 16 | (INT32)pRtpHeader[6] << 8 | pRtpHeader[7];
*pSsrc = (INT32)pRtpHeader[8] << 24 | (INT32)pRtpHeader[9] << 16 | (INT32)pRtpHeader[10] << 8 | pRtpHeader[11];
return TRUE;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 798916 2010-06-12 16:51 Rtsp\Bin\oh yeah.aac
文件 1523956 2010-06-12 16:35 Rtsp\Bin\oh yeah.h264
文件 71168 2010-06-23 22:24 Rtsp\Bin\RtspClientD.exe
文件 224768 2010-06-23 23:03 Rtsp\Bin\RtspServiceD.exe
文件 3831 2010-06-23 22:59 Rtsp\Include\cmd.h
文件 2784 2010-06-12 14:00 Rtsp\Include\string_t.h
文件 736 2009-04-09 16:20 Rtsp\Include\TLock.h
文件 8607 2010-06-17 17:24 Rtsp\Include\VBuffer.h
文件 2249 2008-05-26 12:20 Rtsp\Include\VBufferT.h
文件 2925 2008-07-29 17:48 Rtsp\Network\Rtp.cpp
文件 902 2008-07-29 17:48 Rtsp\Network\Rtp.h
文件 3803 2008-11-12 12:20 Rtsp\Network\Socket.cpp
文件 1174 2010-06-12 14:32 Rtsp\Network\Socket.h
文件 3264 2008-06-20 18:28 Rtsp\Network\Tcp.cpp
文件 1497 2008-04-11 12:05 Rtsp\Network\Tcp.h
文件 4148 2008-07-29 17:48 Rtsp\Network\Udp.cpp
文件 594 2008-07-29 17:48 Rtsp\Network\Udp.h
文件 4508 2008-03-24 10:06 Rtsp\Rtsp\ba
文件 2111 2010-06-12 13:42 Rtsp\Rtsp\Bitstream.cpp
文件 1705 2008-03-13 18:03 Rtsp\Rtsp\Bitstream.h
文件 4345 2010-05-05 12:12 Rtsp\Rtsp\MediaSession.cpp
文件 1168 2010-05-05 11:58 Rtsp\Rtsp\MediaSession.h
文件 2421 2008-08-12 14:13 Rtsp\Rtsp\MediaStream.cpp
文件 1417 2008-08-12 12:21 Rtsp\Rtsp\MediaStream.h
文件 2983 2010-05-05 12:02 Rtsp\Rtsp\MediaStreamAMR.cpp
文件 600 2010-05-05 12:01 Rtsp\Rtsp\MediaStreamAMR.h
文件 3553 2010-05-05 12:01 Rtsp\Rtsp\MediaStreamH263.cpp
文件 576 2010-05-05 12:01 Rtsp\Rtsp\MediaStreamH263.h
文件 5156 2010-05-05 12:00 Rtsp\Rtsp\MediaStreamH264.cpp
文件 769 2010-05-05 12:00 Rtsp\Rtsp\MediaStreamH264.h
............此处省略57个文件信息
- 上一篇:imx250规格书
- 下一篇:pdfjs-2.0.943-dist
相关资源
- RTSP流媒体客户端播放器demo
- YUV测试序列:foreman.cif(1-4)
- FLV测试文件,亲身验证,用过VLC可以
- H264_AAC_TS_MUX_本地文件_1
- H264_AAC_FLV_MUX_本地文件_1
- RTSP_RFC2326(中文版).pdf
- MediaCodec解码H264视频数据
- libx264 将rgb24格式转换为h264 vs2013
- zw_csharp_ffmpeg_rtsp_demo.zip
- Elecard StreamEye
- DDS-RTPS 实时发布订阅协议 DDS互操作协
- h264码流rtp传输demo
- ActiveX RTSP实时流媒体播放器 支持录像
- onvif rtsp流对接
- VLC播放RTSP流
- USB摄像头通过v4l2技术采集、储存视频
- 获取摄像头ip与视频流
- h264编码解码源代码
- linux 使用jrtplib收发h.264视频文件
- V4L2采集YUYV数据x264编码成H264视频
- X264编码H264视频
- rtsp_server C 源码详解与分析
- h264转mp4 VC代码
- live555 RTSP RTCP RTP。live555类关系图,
- Linux PC下UVC摄像头采集并用x264进行编
- 一个可以解码并实时播放H264的播放器
- A10-rtsph264_硬件编码.zip
- udp码流接收录制工具
- GB28181 代码Linux
- H264流媒体RTP打包源代码和相关资料
评论
共有 条评论