hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
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
// Copyright 2019 Fuzhou Rockchip Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
#ifndef EASYMEDIA_DEMUXER_H_
#define EASYMEDIA_DEMUXER_H_
 
#include <list>
 
#include "media_config.h"
#include "media_reflector.h"
#include "stream.h"
 
namespace easymedia
{
 
    DECLARE_FACTORY(Demuxer)
 
    // usage: REFLECTOR(Demuxer)::Create<T>(demuxname, param)
    // T must be the final class type exposed to user
    DECLARE_REFLECTOR(Demuxer)
 
#define DEFINE_DEMUXER_FACTORY(REAL_PRODUCT, FINAL_EXPOSE_PRODUCT)                                                     \
    DEFINE_MEDIA_CHILD_FACTORY(REAL_PRODUCT, REAL_PRODUCT::GetDemuxName(), FINAL_EXPOSE_PRODUCT, Demuxer)              \
    DEFINE_MEDIA_CHILD_FACTORY_EXTRA(REAL_PRODUCT)                                                                     \
    DEFINE_MEDIA_NEW_PRODUCT_BY(REAL_PRODUCT, FINAL_EXPOSE_PRODUCT, GetError() < 0)
 
    class MediaBuffer;
    class _API Demuxer
    {
      public:
        Demuxer(const char* param);
        virtual ~Demuxer() = default;
        static const char* GetDemuxName()
        {
            return nullptr;
        }
 
        // Indicate whether the demuxer do internally decoding
        virtual bool IncludeDecoder()
        {
            return false;
        }
        // Demuxer set the value of MediaConfig
        virtual bool Init(std::shared_ptr<Stream> input, MediaConfig* out_cfg) = 0;
        virtual char** GetComment()
        {
            return nullptr;
        }
        virtual std::shared_ptr<MediaBuffer> Read(size_t request_size = 0) = 0;
 
      public:
        double total_time; // seconds
 
      protected:
        std::string path;
 
        DEFINE_ERR_GETSET()
        DECLARE_PART_FINAL_EXPOSE_PRODUCT(Demuxer)
    };
 
} // namespace easymedia
 
#endif // #ifndef EASYMEDIA_DEMUXER_H_