summaryrefslogtreecommitdiffstats
path: root/xbmc/pvr/PVREdl.cpp
blob: 72a3ee46fd18bfe6ec30be1a3f9f35dcf1b4d88a (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
68
/*
 *  Copyright (C) 2012-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.
 */

#include "PVREdl.h"

#include "FileItem.h"
#include "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h"
#include "cores/EdlEdit.h"
#include "pvr/epg/EpgInfoTag.h"
#include "pvr/recordings/PVRRecording.h"
#include "utils/log.h"

namespace PVR
{

std::vector<EDL::Edit> CPVREdl::GetEdits(const CFileItem& item)
{
  std::vector<PVR_EDL_ENTRY> edl;

  if (item.HasPVRRecordingInfoTag())
  {
    CLog::LogFC(LOGDEBUG, LOGPVR, "Reading EDL for recording: {}",
                item.GetPVRRecordingInfoTag()->m_strTitle);
    edl = item.GetPVRRecordingInfoTag()->GetEdl();
  }
  else if (item.HasEPGInfoTag())
  {
    CLog::LogFC(LOGDEBUG, LOGPVR, "Reading EDL for EPG tag: {}", item.GetEPGInfoTag()->Title());
    edl = item.GetEPGInfoTag()->GetEdl();
  }

  std::vector<EDL::Edit> editlist;
  for (const auto& entry : edl)
  {
    EDL::Edit edit;
    edit.start = entry.start;
    edit.end = entry.end;

    switch (entry.type)
    {
    case PVR_EDL_TYPE_CUT:
      edit.action = EDL::Action::CUT;
      break;
    case PVR_EDL_TYPE_MUTE:
      edit.action = EDL::Action::MUTE;
      break;
    case PVR_EDL_TYPE_SCENE:
      edit.action = EDL::Action::SCENE;
      break;
    case PVR_EDL_TYPE_COMBREAK:
      edit.action = EDL::Action::COMM_BREAK;
      break;
    default:
      CLog::LogF(LOGWARNING, "Ignoring entry of unknown EDL type: {}", entry.type);
      continue;
    }

    editlist.emplace_back(edit);
  }
  return editlist;
}

} // namespace PVR