xbmc
Encoder.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "IEncoder.h"
12 
13 #include <memory>
14 #include <stdint.h>
15 #include <stdio.h>
16 #include <string>
17 
18 namespace XFILE
19 {
20 class CFile;
21 }
22 
23 namespace KODI
24 {
25 namespace CDRIP
26 {
27 
28 constexpr size_t WRITEBUFFER_SIZE = 131072; // 128k buffer
29 
30 class CEncoder : public IEncoder
31 {
32 public:
33  CEncoder();
34  virtual ~CEncoder();
35 
36  bool EncoderInit(const std::string& strFile, int iInChannels, int iInRate, int iInBits);
37  ssize_t EncoderEncode(uint8_t* pbtStream, size_t nNumBytesRead);
38  bool EncoderClose();
39 
40  void SetComment(const std::string& str) { m_strComment = str; }
41  void SetArtist(const std::string& str) { m_strArtist = str; }
42  void SetTitle(const std::string& str) { m_strTitle = str; }
43  void SetAlbum(const std::string& str) { m_strAlbum = str; }
44  void SetAlbumArtist(const std::string& str) { m_strAlbumArtist = str; }
45  void SetGenre(const std::string& str) { m_strGenre = str; }
46  void SetTrack(const std::string& str) { m_strTrack = str; }
47  void SetTrackLength(int length) { m_iTrackLength = length; }
48  void SetYear(const std::string& str) { m_strYear = str; }
49 
50 protected:
51  virtual ssize_t Write(const uint8_t* pBuffer, size_t iBytes);
52  virtual ssize_t Seek(ssize_t iFilePosition, int iWhence);
53 
54 private:
55  bool FileCreate(const std::string& filename);
56  bool FileClose();
57  ssize_t FileWrite(const uint8_t* pBuffer, size_t iBytes);
58  ssize_t FlushStream();
59 
60  std::unique_ptr<XFILE::CFile> m_file;
61 
62  uint8_t m_btWriteBuffer[WRITEBUFFER_SIZE]; // 128k buffer for writing to disc
63  size_t m_dwWriteBufferPointer{0};
64 };
65 
66 } /* namespace CDRIP */
67 } /* namespace KODI */
Definition: Scraper.h:41
Definition: Encoder.h:30
Definition: SimpleFS.h:27
Controller configuration window.
Definition: AudioDecoder.h:18
Definition: IEncoder.h:21