~phablet-team/aethercast/fix-for-microsoft-dongle

« back to all changes in this revision

Viewing changes to src/mcs/streaming/rtpsender.h

Add hardware encoding and video streaming support.

The hardware encoding is currently only for Android 5.x based devices. On all others encoding will simply not work. The streaming part of aethercast (MPEGTS packetizing, RTP sending) as based on some code from Android.

Approved by PS Jenkins bot, Thomas Voß, Jim Hodapp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3, as published
 
6
 * by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 */
 
17
 
 
18
#ifndef MCS_STREAMING_RTPSENDER_H_
 
19
#define MCS_STREAMING_RTPSENDER_H_
 
20
 
 
21
#include <gio/gio.h>
 
22
 
 
23
#include <memory>
 
24
#include <queue>
 
25
#include <thread>
 
26
#include <mutex>
 
27
#include <condition_variable>
 
28
 
 
29
#include "mcs/scoped_gobject.h"
 
30
 
 
31
#include "mcs/video/buffer.h"
 
32
#include "mcs/video/bufferqueue.h"
 
33
 
 
34
#include "mcs/streaming/transportsender.h"
 
35
 
 
36
namespace mcs {
 
37
namespace streaming {
 
38
 
 
39
class RTPSender : public std::enable_shared_from_this<RTPSender>,
 
40
                  public TransportSender {
 
41
public:
 
42
    static TransportSender::Ptr Create(const std::string &address, int port);
 
43
 
 
44
    ~RTPSender();
 
45
 
 
46
    bool Queue(const mcs::video::Buffer::Ptr &packets) override;
 
47
 
 
48
    int32_t LocalPort() const override;
 
49
 
 
50
private:
 
51
    RTPSender();
 
52
 
 
53
    RTPSender::Ptr FinalizerConstruction(const std::string &address, int port);
 
54
 
 
55
    void ThreadLoop();
 
56
 
 
57
private:
 
58
    bool running_;
 
59
    int fd_;
 
60
    uint32_t rtp_sequence_number_;
 
61
    std::thread worker_thread_;
 
62
    mcs::video::BufferQueue::Ptr queue_;
 
63
    int64_t bytes_sent_;
 
64
    int32_t local_port_;
 
65
};
 
66
 
 
67
} // namespace streaming
 
68
} // namespace mcs
 
69
 
 
70
#endif