Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
isource.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_sndio/isource.h
10//! @brief Source interface.
11
12#ifndef ROC_SNDIO_ISOURCE_H_
13#define ROC_SNDIO_ISOURCE_H_
14
16#include "roc_packet/ntp.h"
17#include "roc_sndio/iterminal.h"
18
19namespace roc {
20namespace sndio {
21
22//! Source interface.
23class ISource : public ITerminal, public audio::IFrameReader {
24public:
25 virtual ~ISource();
26
27 //! Source state.
28 enum State {
29 //! Source is running and active.
30 //! It is producing some sound.
32
33 //! Source is running but is inactive.
34 //! It is producing silence. It may be safely paused.
36
37 //! Source is paused.
38 //! It's not producing anything.
39 Paused
40 };
41
42 //! Get current source state.
43 virtual State state() const = 0;
44
45 //! Pause reading.
46 virtual void pause() = 0;
47
48 //! Resume paused reading.
49 //! @returns
50 //! false if an error occured.
51 virtual bool resume() = 0;
52
53 //! Restart reading from the beginning.
54 //! @remarks
55 //! If the reading is paused, it's automatically resumed.
56 //! @returns
57 //! false if an error occured.
58 virtual bool restart() = 0;
59
60 //! Adjust source clock to match consumer clock.
61 //! @remarks
62 //! Invoked regularly after reading every or a several frames.
63 //! @p timestamp defines the time in NTP domain when the last sample of the last
64 //! frame read from source is going to be actually processed by consumer.
65 virtual void reclock(packet::ntp_timestamp_t timestamp) = 0;
66};
67
68} // namespace sndio
69} // namespace roc
70
71#endif // ROC_SNDIO_ISOURCE_H_
Frame reader interface.
Source interface.
Definition isource.h:23
State
Source state.
Definition isource.h:28
@ Idle
Source is running but is inactive. It is producing silence. It may be safely paused.
Definition isource.h:35
@ Paused
Source is paused. It's not producing anything.
Definition isource.h:39
@ Playing
Source is running and active. It is producing some sound.
Definition isource.h:31
virtual State state() const =0
Get current source state.
virtual bool restart()=0
Restart reading from the beginning.
virtual void reclock(packet::ntp_timestamp_t timestamp)=0
Adjust source clock to match consumer clock.
virtual bool resume()=0
Resume paused reading.
virtual void pause()=0
Pause reading.
Base interface for sinks and sources.
Definition iterminal.h:23
Frame reader interface.
Terminal interface.
uint64_t ntp_timestamp_t
NTP timestamp.
Definition units.h:91
Root namespace.
Utitilies for NTP timestamp.