⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wrtspsvr.cpp

📁 rtsp协议的主要实现代码.对开发流媒体
💻 CPP
字号:
// WRtspSvr.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include "Type.h"
#include "RTSPServer.h"
#include "WAVAudioFileServerMediaSubsession.h"

static void announceStream(RTSPServer* rtspServer, ServerMediaSession* sms,
						   char const* streamName, char const* inputFileName); // fwd

// To make the second and subsequent client for each stream reuse the same
// input stream as the first client (rather than playing the file from the
// start for each client), change the following "False" to "True":
Boolean reuseFirstSource = False;
char const* descriptionString
= "Session streamed by \"testOnDemandRTSPServer\"";

int main(int argc, char* argv[])
{
	printf("Hello World!\n");
	RTSPServer fRTSPServer(554);
	
	// A WAV audio stream:
	{
		char const* streamName = "wavAudioTest";
		char const* inputFileName = "test.wav";
		ServerMediaSession* sms
			= new ServerMediaSession(streamName, streamName,descriptionString);
		// To convert 16-bit PCM data to 8-bit u-law, prior to streaming,
		// change the following to True:
		Boolean convertToULaw = False;
		sms->addSubsession(WAVAudioFileServerMediaSubsession::createNew(inputFileName, reuseFirstSource, "audio",convertToULaw));
		fRTSPServer.addServerMediaSession(sms);
		
		announceStream(&fRTSPServer, sms, streamName, inputFileName);
	}
	
	fRTSPServer.RunServer();
	return 0;
}

static void announceStream(RTSPServer* rtspServer, ServerMediaSession* sms,
						   char const* streamName, char const* inputFileName) {
	char* url = rtspServer->rtspURL(sms);
	cout << "\n\"" << streamName << "\" stream, from the file \""
		<< inputFileName << "\"\n";
	cout << "Play this stream using the URL \"" << url << "\"\n";
	delete[] url;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -