blob: 644296de4aa7a4d97c29e612a88f84feffb3285f (
plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "IEncoder.h"
#include <memory>
#include <stdint.h>
#include <stdio.h>
#include <string>
namespace XFILE
{
class CFile;
}
namespace KODI
{
namespace CDRIP
{
constexpr size_t WRITEBUFFER_SIZE = 131072; // 128k buffer
class CEncoder : public IEncoder
{
public:
CEncoder();
virtual ~CEncoder();
bool EncoderInit(const std::string& strFile, int iInChannels, int iInRate, int iInBits);
ssize_t EncoderEncode(uint8_t* pbtStream, size_t nNumBytesRead);
bool EncoderClose();
void SetComment(const std::string& str) { m_strComment = str; }
void SetArtist(const std::string& str) { m_strArtist = str; }
void SetTitle(const std::string& str) { m_strTitle = str; }
void SetAlbum(const std::string& str) { m_strAlbum = str; }
void SetAlbumArtist(const std::string& str) { m_strAlbumArtist = str; }
void SetGenre(const std::string& str) { m_strGenre = str; }
void SetTrack(const std::string& str) { m_strTrack = str; }
void SetTrackLength(int length) { m_iTrackLength = length; }
void SetYear(const std::string& str) { m_strYear = str; }
protected:
virtual ssize_t Write(const uint8_t* pBuffer, size_t iBytes);
virtual ssize_t Seek(ssize_t iFilePosition, int iWhence);
private:
bool FileCreate(const std::string& filename);
bool FileClose();
ssize_t FileWrite(const uint8_t* pBuffer, size_t iBytes);
ssize_t FlushStream();
std::unique_ptr<XFILE::CFile> m_file;
uint8_t m_btWriteBuffer[WRITEBUFFER_SIZE]; // 128k buffer for writing to disc
size_t m_dwWriteBufferPointer{0};
};
} /* namespace CDRIP */
} /* namespace KODI */
|