1 #pragma once
2 
3 #include <arpa/inet.h>
4 #include <errno.h>
5 #include <log/log.h>
6 #include <netinet/in.h>
7 #include <stdio.h>
8 #include <sys/socket.h>
9 #include <sys/types.h>
10 #include <unistd.h>
11 #include <string>
12 #include <thread>
13 
14 /**
15  * IP Streamer class to send TS data to a specified socket for testing IPTV frontend functions
16  * e.g. tuning and playback.
17  */
18 
19 class IpStreamer {
20   public:
21     // Constructor for IP Streamer object
22     IpStreamer();
23 
24     // Destructor for IP Streamer object
25     ~IpStreamer();
26 
27     // Starts a thread to read data from a socket
28     void startIpStream();
29 
30     // Stops the reading thread started by startIpStream
31     void stopIpStream();
32 
33     // Thread function that consumes data from a socket
34     void ipStreamThreadLoop(FILE* fp);
35 
getFilePath()36     std::string getFilePath() { return mFilePath; };
37 
38   private:
39     int mSockfd = -1;
40     FILE* mFp = nullptr;
41     bool mIsIpV4 = true;                                         // By default, set to IPV4
42     int mPort = 12345;                                           // default port
43     int mBufferSize = 188;                                       // bytes
44     int mSleepTime = 1;                                          // second
45     std::string mIpAddress = "127.0.0.1";                        // default IP address
46     std::string mFilePath = "/data/local/tmp/segment000000.ts";  // default path for TS file
47     std::thread mIpStreamerThread;
48 };