File: ServerStreamData.hpp

package info (click to toggle)
soapyremote 0.5.2-4.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 608 kB
  • sloc: cpp: 7,724; makefile: 13
file content (66 lines) | stat: -rw-r--r-- 1,418 bytes parent folder | download | duplicates (5)
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
// Copyright (c) 2015-2016 Josh Blum
// SPDX-License-Identifier: BSL-1.0

#pragma once
#include "SoapyRPCSocket.hpp"
#include "ThreadPrioHelper.hpp"
#include <csignal> //sig_atomic_t
#include <string>
#include <thread>

class SoapyStreamEndpoint;

namespace SoapySDR
{
    class Device;
    class Stream;
}

/*!
 * Server-side stream data for client handler.
 * This class manages a recv/send endpoint,
 * and a thread to handle that endpoint.
 */
class ServerStreamData
{
public:
    ServerStreamData(void);
    ~ServerStreamData(void);

    SoapySDR::Device *device;
    SoapySDR::Stream *stream;
    std::string format;
    size_t chanMask;
    double priority;

    //this ID identifies the stream to the remote host
    int streamId;

    //datagram socket for stream endpoint
    SoapyRPCSocket *streamSock;

    //datagram socket for status endpoint
    SoapyRPCSocket *statusSock;

    //remote side of the stream endpoint
    SoapyStreamEndpoint *endpoint;

    //hooks to start/stop work
    void startSendThread(void);
    void startRecvThread(void);
    void startStatThread(void);
    void stopThreads(void);

    //worker implementations
    void recvEndpointWork(void);
    void sendEndpointWork(void);
    void statEndpointWork(void);

private:
    //worker thread for this stream
    std::thread *streamThread;
    std::thread *statusThread;

    //signal done to the thread
    sig_atomic_t done;
};