summaryrefslogtreecommitdiffstats
path: root/xbmc/cores/VideoPlayer/VideoPlayerAudioID3.h
blob: fe97a5e78511a728e9c4f5a1b3c1ef4fc073cad0 (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
/*
 *  Copyright (C) 2005-2022 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 "DVDMessageQueue.h"
#include "IVideoPlayer.h"
#include "Interface/TimingConstants.h"
#include "threads/CriticalSection.h"
#include "threads/Thread.h"

#include <memory>
#include <string>
#include <vector>

#include <taglib/id3v1tag.h>
#include <taglib/id3v2tag.h>
#include <taglib/tstringlist.h>

class CVideoPlayerAudioID3 : public IDVDStreamPlayer, private CThread
{
public:
  explicit CVideoPlayerAudioID3(CProcessInfo& processInfo);
  ~CVideoPlayerAudioID3() override;

  bool CheckStream(const CDVDStreamInfo& hints);
  void Flush();
  void WaitForBuffers();

  bool OpenStream(CDVDStreamInfo hints) override;
  void CloseStream(bool bWaitForBuffers) override;
  void SendMessage(std::shared_ptr<CDVDMsg> pMsg, int priority = 0) override;
  void FlushMessages() override;
  bool IsInited() const override;
  bool AcceptsData() const override;
  bool IsStalled() const override;

protected:
  void OnExit() override;
  void Process() override;

private:
  void ProcessID3(const unsigned char* data, unsigned int length) const;
  void ProcessID3v1(const TagLib::ID3v1::Tag* tag) const;
  void ProcessID3v2(const TagLib::ID3v2::Tag* tag) const;

  static std::vector<std::string> GetID3v2StringList(const TagLib::ID3v2::FrameList& frameList);
  static std::vector<std::string> StringListToVectorString(const TagLib::StringList& stringList);

  int m_speed = DVD_PLAYSPEED_NORMAL;
  CCriticalSection m_critSection;
  CDVDMessageQueue m_messageQueue;
};