aboutsummaryrefslogtreecommitdiff
path: root/Src/playlist/M3U8Writer.cpp
blob: 729722166220b6b407bd4e7324a768ec76a63ae5 (plain) (blame)
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
#include "M3U8Writer.h"
#include "../nu/AutoChar.h"
#include <bfc/platform/types.h>

M3U8Writer::M3U8Writer() : fp(0)
{
}

int M3U8Writer::Open(const wchar_t *filename)
{
	fp = _wfopen(filename, L"wt");
	if (!fp)
		return 0;
  
	fputs( "\xEF\xBB\xBF", fp );
	fprintf(fp,"#EXTM3U\n");

	return 1;
}

void M3U8Writer::Write(const wchar_t *filename)
{
	fwprintf(fp,L"%s\n", filename);
}

void M3U8Writer::Write(const wchar_t *filename, const wchar_t *title, int length)
{
	fprintf( fp, "#EXTINF:%d,%s\n%s\n", length, (char *) AutoChar( title, CP_UTF8 ), (char *) AutoChar( filename, CP_UTF8 ) );
}

void M3U8Writer::Write( const wchar_t *p_filename, const wchar_t *p_title, const wchar_t *p_extended_infos, int p_length )
{
	fprintf( fp, "#EXTINF:%d %s,%s\n%s\n", p_length, (char *)AutoChar( p_extended_infos, CP_UTF8 ), (char *)AutoChar( p_title, CP_UTF8 ), (char *)AutoChar( p_filename, CP_UTF8 ) );
}

void M3U8Writer::Close()
{
	fclose(fp);
}