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

📄 zzlfilewriter.h

📁 mysee网络直播源代码Mysee Lite是Mysee独立研发的网络视频流媒体播放系统。在应有了P2P技术和一系列先进流媒体技术之后
💻 H
字号:
/*
*  Openmysee
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
*/
#pragma once

class ZZLFileWriter
{
public:
	ZZLFileWriter(void);
	virtual ~ZZLFileWriter(void);

	// 初始化
	bool Init(string path, string name);

	// 媒体类型数据
	bool SetMediaType(const TVMEDIATYPESECTION& audioType, BYTE* audioData, const TVMEDIATYPESECTION& videoType, BYTE* videoData);

	// 新的Sample
	bool PutSample(const SampleHeader& header, BYTE* pData);

	// 获取最新的码率统计
	double GetBitRate();

	//设置是否是单音频
	void SetIsSingleAudio(BOOL abAudio);

private:
	bool SaveSample(UINT dataOff, const UINT allSize);	// 保存Sample
	bool SaveBlock(const PBYTE data, UINT size);		// 保存Block
	bool RemoveOldTmpFile(string path);					// 删除以前使用的临时文件
	bool SaveBitRate();									// 保存码率到配置文件

private:
	LONGLONG mLLMaxAudioTime;
	LONGLONG mLLMaxVideoTime;

	typedef CRITICAL_SECTION C_S;
	C_S			zzlfile_cs;				// 调用PutSample的互斥变量
	string		savePath;				// 保存的路径
	string		chnlName;				// 节目名
	UINT		blockCount;				// 块数

	// 这些成员用于生成zzl文件
	HANDLE		zzlHandle;				// zzl文件句柄
	UINT		dataOffset;				// 数据偏移量
	time_t		startTime;				// 起始时间
	time_t		endTime;				// 结束时间
	const float FILE_VERSION;			// ZZL文件的版本

	BOOL		mbIsSingleAudio;			//单音频

	// 这些成员用于生成节目文件(数据文件//配置文件)
	HANDLE		dataHandle;				// 数据文件的句柄
	HANDLE		keySampleHandle;		// 关键帧文件的句柄
	HANDLE		configHandle;			// 配置文件的句柄
	UINT		dataFileCount;			// 数据文件的个数

	BYTE		newBlock[BLOCK_SIZE];	// 正在生成的块
	UINT		newBlockSize;			// newBlock的大小
	BYTE*		sampleBuffer;			// 将Sample存入Block的中转站
	UINT		sampleBufferSize;		// sample缓存的大小
	time_t		firstSampleTime;		// 当前块中第一个sample的starttime
	time_t		firstKeySampleTime;		// 当前块中第一个keysample的starttime

	LONGLONG	audioDataSize;			// 音频Sample的总大小
	LONGLONG	audioStartTime;			// 第一个音频Sample的时间戳
	LONGLONG	audioEndTime;			// 最近一个音频Sample的时间戳
	LONGLONG	videoDataSize;			// 视频Sample的总大小
	LONGLONG	videoStartTime;			// 第一个视频Sample的时间戳
	LONGLONG	videoEndTime;			// 最近一个视频Sample的时间戳

	enum {
		BLOCK_OF_DATA_FILE = 163840,		// 每X块数据保存成独立的数据
	};
};

⌨️ 快捷键说明

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