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

📄 input.cpp

📁 《Visual C++视频/音频开发实用工程案例精选》一书的源代码
💻 CPP
字号:
/**************************************************************************************
 *                                                                                    *
 *                                                                                    *
 **************************************************************************************/

#include "Input.h"



MediaInput::MediaInput()
{
	this->inputInternet = new MediaInputInternet();
	this->inputFile     = new MediaInputFile();

	this->input = NULL;
}



MediaInput::~MediaInput()
{
	delete this->inputFile;
	delete this->inputInternet;
}



media_type_t MediaInput::GetType()
{
	return MEDIA_TYPE_INPUT;
}

char        *MediaInput::GetName()
{	
	if(this->input)
		return this->input->GetName();

	return "Input Wrapper";
}

MP_RESULT MediaInput::Connect(MediaItem *item)
{
	return MP_RESULT_ERROR;
}

MP_RESULT MediaInput::ReleaseConnections()
{
	return MP_RESULT_ERROR;
}

DWORD         MediaInput::GetCaps()
{
	if(this->input)
		return this->input->GetCaps();
	
	return 0;
}

MP_RESULT     MediaInput::Configure(HINSTANCE hInstance, HWND hwnd)
{
	return MP_RESULT_ERROR;
}



MP_RESULT MediaInput::Open(char *url, media_input_mode_t mode)
{
	if(this->input != NULL)
		return MP_RESULT_ERROR;



	if(url != NULL) {

		if(strstr(url, "http://") != NULL || strstr(url, "ftp://") != NULL ||
		   strstr(url, "HTTP://") != NULL || strstr(url, "FTP://") != NULL) {

			if(this->inputInternet->Open(url, mode) != MP_RESULT_OK)
				return MP_RESULT_ERROR;

			this->input = this->inputInternet;

			return MP_RESULT_OK;
		}
		else {
			
			if(this->inputFile->Open(url, mode) != MP_RESULT_OK)
				return MP_RESULT_ERROR;

			this->input = this->inputFile;

			return MP_RESULT_OK;
		}
	}

	return MP_RESULT_ERROR;
}

long MediaInput::GetSize()
{
	if(this->input != NULL)
		return this->input->GetSize();

	return MP_RESULT_ERROR;
}

long MediaInput::GetBufferSize()
{
	if(this->input != NULL)
		return this->input->GetBufferSize();

	return MP_RESULT_ERROR;
}

long MediaInput::GetBufferPosition()
{
	if(this->input != NULL)
		return this->input->GetBufferPosition();

	return MP_RESULT_ERROR;
}

long MediaInput::GetBufferingSize()
{
	if(this->input != NULL)
		return this->input->GetBufferingSize();

	return MP_RESULT_ERROR;
}

unsigned int MediaInput::Read(MediaBuffer *mb, unsigned int size)
{
	if(this->input != NULL)
		return this->input->Read(mb, size);

	return MP_RESULT_ERROR;
}

unsigned int MediaInput::Seek(int size, media_input_seek_t method)
{
	if(this->input != NULL)
		return this->input->Seek(size, method);

	return MP_RESULT_ERROR;
}

unsigned int  MediaInput::GetLine(MediaBuffer *mb)
{
	if(this->input != NULL)
		return this->input->GetLine(mb);

	return 0;
}

BOOL MediaInput::EndOfFile()
{
	if(this->input != NULL)
		return this->input->EndOfFile();

	return FALSE;
}

MP_RESULT MediaInput::Close()
{
	if(this->input != NULL)
		this->input->Close();

	this->input = NULL;

	return MP_RESULT_ERROR;
}

⌨️ 快捷键说明

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