[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / cores / paplayer / ICodec.h
blob1b452808525c547fa3a198880c18eb4339d73bd9
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "cores/AudioEngine/Utils/AEAudioFormat.h"
12 #include "filesystem/File.h"
13 #include "music/tags/MusicInfoTag.h"
15 #include <string>
17 #define READ_EOF -1
18 #define READ_SUCCESS 0
19 #define READ_ERROR 1
21 class CFileItem;
23 class ICodec
25 public:
26 ICodec()
28 m_TotalTime = 0;
29 m_bitRate = 0;
30 m_bitsPerSample = 0;
31 m_bitsPerCodedSample = 0;
33 virtual ~ICodec() = default;
35 // Virtual functions that all codecs should implement. Note that these may need
36 // enhancing and or refactoring at a later date. It works currently well for MP3 and
37 // APE codecs.
39 // Init(filename)
40 // This routine should handle any initialization necessary. At a minimum it needs to:
41 // 1. Load any dlls and make sure any buffers etc. are allocated.
42 // 2. Load the file (or at least attempt to load it)
43 // 3. Fill in the m_TotalTime, m_SampleRate, m_BitsPerSample and m_Channels parameters.
44 virtual bool Init(const CFileItem &file, unsigned int filecache)=0;
46 virtual bool CanSeek() {return true;}
48 // Seek()
49 // Should seek to the appropriate time (in ms) in the file, and return the
50 // time to which we managed to seek (in the case where seeking is problematic)
51 // This is used in FFwd/Rewd so can be called very often.
52 virtual bool Seek(int64_t iSeekTime)=0;
54 // ReadPCM()
55 // Decodes audio into pBuffer up to size bytes. The actual amount of returned data
56 // is given in actualsize. Returns READ_SUCCESS on success. Returns READ_EOF when
57 // the data has been exhausted, and READ_ERROR on error.
58 virtual int ReadPCM(uint8_t* pBuffer, size_t size, size_t* actualsize) = 0;
60 virtual int ReadRaw(uint8_t **pBuffer, int *bufferSize) { return READ_ERROR; }
62 // CanInit()
63 // Should return true if the codec can be initialized
64 // eg. check if a dll needed for the codec exists
65 virtual bool CanInit()=0;
67 // set the total time - useful when info comes from a preset tag
68 virtual void SetTotalTime(int64_t totaltime) {}
70 virtual bool IsCaching() const {return false;}
71 virtual int GetCacheLevel() const {return -1;}
73 int64_t m_TotalTime; // time in ms
74 int m_bitRate;
75 int m_bitsPerSample;
76 int m_bitsPerCodedSample;
77 std::string m_CodecName;
78 MUSIC_INFO::CMusicInfoTag m_tag;
79 XFILE::CFile m_file;
80 AEAudioFormat m_format;