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

« back to all changes in this revision

Viewing changes to src/mcs/streaming/mpegtspacketizer.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 2012, The Android Open Source Project
 
3
 * Copyright (C) 2016 Canonical, Ltd.
 
4
 *
 
5
 * Licensed under the Apache License, Version 2.0 (the "License");
 
6
 * you may not use this file except in compliance with the License.
 
7
 * You may obtain a copy of the License at
 
8
 *
 
9
 *     http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
11
 * Unless required by applicable law or agreed to in writing, software
 
12
 * distributed under the License is distributed on an "AS IS" BASIS,
 
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 * See the License for the specific language governing permissions and
 
15
 * limitations under the License.
 
16
 */
 
17
 
 
18
#ifndef MCS_STREAMING_MPEGTSPACKETIZER_H_
 
19
#define MCS_STREAMING_MPEGTSPACKETIZER_H_
 
20
 
 
21
#include <memory>
 
22
#include <vector>
 
23
 
 
24
#include "mcs/streaming/packetizer.h"
 
25
 
 
26
namespace mcs {
 
27
namespace streaming {
 
28
 
 
29
class MPEGTSPacketizer : public Packetizer {
 
30
public:
 
31
    static Packetizer::Ptr Create();
 
32
 
 
33
    ~MPEGTSPacketizer();
 
34
 
 
35
    TrackId AddTrack(const TrackFormat &format) override;
 
36
 
 
37
    void SubmitCSD(TrackId track_index, const video::Buffer::Ptr &buffer) override;
 
38
 
 
39
    bool Packetize(TrackId track_index, const video::Buffer::Ptr &access_unit,
 
40
                   video::Buffer::Ptr *packets, int flags = 0) override;
 
41
 
 
42
private:
 
43
    MPEGTSPacketizer();
 
44
 
 
45
private:
 
46
    void InitCrcTable();
 
47
    uint32_t CalcCrc32(const uint8_t *start, size_t size) const;
 
48
 
 
49
private:
 
50
    struct Track;
 
51
 
 
52
private:
 
53
    unsigned int pat_continuity_counter_;
 
54
    unsigned int pmt_continuity_counter_;
 
55
    uint32_t crc_table_[256];
 
56
    std::vector<std::shared_ptr<Track>> tracks_;
 
57
    std::vector<video::Buffer::Ptr> program_info_descriptors_;
 
58
};
 
59
 
 
60
} // namespace streaming
 
61
} // namespace mcs
 
62
 
 
63
#endif