GCC Code Coverage Report


Directory: ./
File: playlist/PlaylistEntryMedia.h
Date: 2026-12-01 12:27:28
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 2 2 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 "fpp-json-fwd.h"
15 #include <atomic>
16 #include <mutex>
17 #include <string>
18
19 #include "PlaylistEntryBase.h"
20 #include "mediaoutput/StreamSlotManager.h"
21 #include "mediaoutput/mediaoutput.h"
22
23 class PlaylistEntryMedia : public PlaylistEntryBase {
24 public:
25 PlaylistEntryMedia(Playlist* playlist, PlaylistEntryBase* parent = NULL);
26 virtual ~PlaylistEntryMedia();
27
28 virtual int Init(Json::Value& config) override;
29
30 virtual int PreparePlay();
31 virtual void PrepareAhead() override;
32 virtual int StartPlaying(void) override;
33 virtual int Process(void) override;
34 virtual int Stop(void) override;
35
36 virtual void Pause() override;
37 virtual bool IsPaused() override;
38 virtual void Resume() override;
39
40 virtual void Dump(void) override;
41
42 virtual Json::Value GetConfig(void) override;
43 virtual Json::Value GetMqttStatus(void) override;
44
45 21691 std::string GetMediaName(void) { return m_mediaFilename; }
46 int GetStreamSlot(void) { return m_streamSlot; }
47 bool IsBackgroundSlot(void) { return m_streamSlot > 1; }
48
49 // Companion streams started alongside this entry's own media and stopped
50 // with it -- e.g. a second language on another audio device, or a second
51 // video on a second HDMI. Declared on the entry so they share its
52 // lifetime instead of having to be fired and cleaned up by hand.
53 struct ExtraMedia {
54 std::string mediaName;
55 int slot = 2;
56 std::string videoOut;
57 bool sync = false;
58 };
59
60 virtual uint64_t GetLengthInMS() override;
61 virtual uint64_t GetElapsedMS() override;
62
63 bool HasExtraAtEnd();
64 // Whether the media's sound has reached the output yet (see
65 // MediaOutputBase::IsAudible). True when there is no media output.
66 bool IsAudible();
67 int32_t GetMediaOffsetMS();
68 // Once the media has ended: when the last of its sound is heard
69 // (GetMonotonicTimeMS()), or 0 if not known (MediaOutputBase::SoundEndMS).
70 53 uint64_t SoundEndMS() const { return m_soundEndMs; }
71
72 int m_status;
73
74 long long m_openTime;
75 long long m_startTime;
76 uint64_t m_soundEndMs = 0;
77 // With a media offset the MultiSync start goes out from Process() once the
78 // offset has passed. Once: there used to be no flag, so it was resent on
79 // every main-loop tick for the whole song and remotes restarted their media
80 // on each one.
81 bool m_syncStartSent = false;
82 // Set while Resume() reopens the paused media through PreparePlay(): the
83 // same file, not a new random pick, and no play-once check (the entry is
84 // already playing -- that check made Resume() finish a play-once entry).
85 bool m_resuming = false;
86 static int m_openStartDelay;
87
88 private:
89 int OpenMediaOutput(void);
90 int CloseMediaOutput(void);
91
92 unsigned int m_fileSeed;
93 int GetFileList(void);
94 std::string GetNextRandomFile(void);
95
96 /// startMS > 0 resumes the companions at that offset instead of from zero.
97 void StartExtraMedia(int startMS = 0);
98 void StopExtraMedia(void);
99
100 std::vector<ExtraMedia> m_extraMedia;
101 bool m_extraMediaStarted = false;
102
103 std::string m_mediaFilename;
104 std::string m_mediaPrefix;
105 std::string m_videoOutput;
106 int m_streamSlot; // stream slot (1-5), default 1
107 MediaOutputStatus* m_slotStatus; // per-slot status pointer
108 MediaOutputBase* m_mediaOutput;
109 std::mutex m_mediaOutputLock;
110
111 std::atomic<uint64_t> m_duration;
112
113 std::string m_fileMode;
114 std::vector<std::string> m_files;
115 // A random pick made by PrepareAhead(), which the next PreparePlay()
116 // plays instead of drawing again.
117 std::string m_preparedFile;
118
119 std::atomic<int> m_pausedTime;
120 MediaOutputStatus m_pausedStatus;
121 };
122