AVPKit
BufferSource.h
1 /*******************************************************************************
2  * Copyright (c) 2024, 2026, Olivier Ayache. All rights reserved.
3  *
4  * This file is part of AVPKit.
5  *
6  * AVPKit is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * AVPKit is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with AVPKit. If not, see <http://www.gnu.org/licenses/>.
18  *******************************************************************************/
19 
20 #ifndef BUFFERSOURCE_H
21 #define BUFFERSOURCE_H
22 
23 #include <com/avpkit/core/IAudioSamples.h>
24 #include <com/avpkit/core/IVideoPicture.h>
25 #include <com/avpkit/core/IRational.h>
26 #include <com/avpkit/core/IBufferSource.h>
27 #include <com/avpkit/core/MediaFilter.h>
28 #include <com/avpkit/ferry/RefPointer.h>
29 
30 
31 extern "C" {
32 #include "libavfilter/avfilter.h"
33 #include "libavfilter/buffersrc.h"
34 #include "libavutil/opt.h"
35 }
36 
37 
38 namespace com {
39  namespace avpkit {
40  namespace core {
41 
42  using namespace com::avpkit::ferry;
43 
44  class BufferSource : public IBufferSource, public MediaFilter {
45  VS_JNIUTILS_REFCOUNTED_OBJECT_PRIVATE_MAKE(BufferSource)
46  public:
47  static BufferSource* make(AVFilterGraph* graph, IAudioSamples::Format format,
48  int channels,
49  int sample_rate,
50  IRational* time_base,
51  IAudioSamples::ChannelLayout channel_layout);
52 
53  static BufferSource* make(AVFilterGraph* graph, IPixelFormat::Type format,
54  int width,
55  int height,
56  IRational* frame_rate,
57  IRational* time_base);
58 
59  static BufferSource* make(AVFilterGraph* graph, IVideoPicture* picture,
60  IRational* frame_rate);
61 
62  virtual int addAudioSamples(IAudioSamples* samples);
63 
64  virtual int addVideoPicture(IVideoPicture* picture);
65 
66 
67  protected:
68  BufferSource();
69  virtual ~BufferSource();
70  private:
71  AVFilterGraph* mFilterGraph;
72  AVBufferSrcParameters* mParams;
73  int mSampleRate;
75  };
76 
77  }
78  }
79 }
80 
81 #endif /* BUFFERSOURCE_H */
82 
A set of raw (decoded) samples, plus a timestamp for when to play those samples relative to other ite...
Definition: IAudioSamples.h:38
Format
The format we use to represent audio.
Definition: IAudioSamples.h:46
This class wraps represents a Rational number for the AVPKit.
Definition: IRational.h:43
Represents one raw (undecoded) picture in a video stream, plus a timestamp for when to display that v...
Definition: IVideoPicture.h:40
This class is only useful from C++.
Definition: RefPointer.h:47
This library contains routines used by AVPKit libraries for "ferry"ing Java objects to and from nativ...
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...