GCC Code Coverage Report


Directory: ./
File: playlist/PlaylistEntryMedia.h
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 #pragma once
2 /*
3 * This file is part of the Falcon Player (FPP) and is Copyright (C)
4 * 2013-2022 by the Falcon Player Developers.
5 *
6 * The Falcon Player (FPP) is free software, and is covered under
7 * multiple Open Source licenses. Please see the included 'LICENSES'
8 * file for descriptions of what files are covered by each license.
9 *
10 * This source file is covered under the LGPL v2.1 as described in the
11 * included LICENSE.LGPL file.
12 */
13
14 #include <mutex>
15 #include <string>
16 #include "fpp-json-fwd.h"
17
18 #include "PlaylistEntryBase.h"
19 #include "mediaoutput/mediaoutput.h"
20 #include "mediaoutput/StreamSlotManager.h"
21
22 class PlaylistEntryMedia : public PlaylistEntryBase {
23 public:
24 PlaylistEntryMedia(Playlist* playlist, PlaylistEntryBase* parent = NULL);
25 virtual ~PlaylistEntryMedia();
26
27 virtual int Init(Json::Value& config) override;
28
29 virtual int PreparePlay();
30 virtual int StartPlaying(void) override;
31 virtual int Process(void) override;
32 virtual int Stop(void) override;
33
34 virtual void Pause() override;
35 virtual bool IsPaused() override;
36 virtual void Resume() override;
37
38 virtual void Dump(void) override;
39
40 virtual Json::Value GetConfig(void) override;
41 virtual Json::Value GetMqttStatus(void) override;
42
43 26158 std::string GetMediaName(void) { return m_mediaFilename; }
44 int GetStreamSlot(void) { return m_streamSlot; }
45 bool IsBackgroundSlot(void) { return m_streamSlot > 1; }
46
47 // Companion streams started alongside this entry's own media and stopped
48 // with it -- e.g. a second language on another audio device, or a second
49 // video on a second HDMI. Declared on the entry so they share its
50 // lifetime instead of having to be fired and cleaned up by hand.
51 struct ExtraMedia {
52 std::string mediaName;
53 int slot = 2;
54 std::string videoOut;
55 bool sync = false;
56 };
57
58 virtual uint64_t GetLengthInMS() override;
59 virtual uint64_t GetElapsedMS() override;
60
61 bool HasExtraAtEnd();
62 // Whether the media's sound has reached the output yet (see
63 // MediaOutputBase::IsAudible). True when there is no media output.
64 bool IsAudible();
65 int32_t GetMediaOffsetMS();
66
67 int m_status;
68
69 long long m_openTime;
70 long long m_startTime;
71 // With a media offset the MultiSync start goes out from Process() once the
72 // offset has passed. Once: there used to be no flag, so it was resent on
73 // every main-loop tick for the whole song and remotes restarted their media
74 // on each one.
75 bool m_syncStartSent = false;
76 // Set while Resume() reopens the paused media through PreparePlay(): the
77 // same file, not a new random pick, and no play-once check (the entry is
78 // already playing -- that check made Resume() finish a play-once entry).
79 bool m_resuming = false;
80 static int m_openStartDelay;
81
82 private:
83 int OpenMediaOutput(void);
84 int CloseMediaOutput(void);
85
86 unsigned int m_fileSeed;
87 int GetFileList(void);
88 std::string GetNextRandomFile(void);
89
90 /// startMS > 0 resumes the companions at that offset instead of from zero.
91 void StartExtraMedia(int startMS = 0);
92 void StopExtraMedia(void);
93
94 std::vector<ExtraMedia> m_extraMedia;
95 bool m_extraMediaStarted = false;
96
97 std::string m_mediaFilename;
98 std::string m_mediaPrefix;
99 std::string m_videoOutput;
100 int m_streamSlot; // stream slot (1-5), default 1
101 MediaOutputStatus* m_slotStatus; // per-slot status pointer
102 MediaOutputBase* m_mediaOutput;
103 std::mutex m_mediaOutputLock;
104
105 uint64_t m_duration;
106
107 std::string m_fileMode;
108 std::vector<std::string> m_files;
109
110 int m_pausedTime;
111 MediaOutputStatus m_pausedStatus;
112 };
113