AVPKit
IContainerFormat.cpp
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 #include "IContainerFormat.h"
21 #include "Global.h"
22 #include "ContainerFormat.h"
23 
24 #include "FfmpegIncludes.h"
25 
26 namespace com { namespace avpkit { namespace core
27 {
28  IContainerFormat :: ~IContainerFormat()
29  {
30  }
31 
32  IContainerFormat*
34  {
35  Global::init();
36  return ContainerFormat::make();
37  }
38 
39  int32_t
41  {
42  Global::init();
43  int i = 0;
44  for(AVInputFormat* f = 0;
45  (f = av_iformat_next(f))!=0;
46  ++i)
47  ;
48  return i;
49  }
50 
53  {
54  Global::init();
55  int i = 0;
56  for(AVInputFormat* f = 0;
57  (f = av_iformat_next(f))!=0;
58  ++i)
59  if (i == index) {
61  if (retval)
62  retval->setInputFormat(f);
63  return retval;
64  }
65  return 0;
66  }
67 
68  int32_t
70  {
71  Global::init();
72  int i = 0;
73  for(AVOutputFormat* f = 0;
74  (f = av_oformat_next(f))!=0;
75  ++i)
76  ;
77  return i;
78  }
79 
82  {
83  Global::init();
84  int i = 0;
85  for(AVOutputFormat* f = 0;
86  (f = av_oformat_next(f))!=0;
87  ++i)
88  if (i == index)
89  {
91  if (retval)
92  retval->setOutputFormat(f);
93  return retval;
94  }
95  return 0;
96  }
97 
98 }}}
virtual int32_t setInputFormat(const char *shortName)
Sets the input format for this container.
virtual int32_t setOutputFormat(const char *shortName, const char *url, const char *mimeType)
Sets the output format for this container.
static void init()
Internal Only.
Definition: Global.cpp:157
Specifies format information than can be used to configure an IContainer for input or output.
static int32_t getNumInstalledInputFormats()
Get the number of input formats this install can demultiplex (read) from.
static IContainerFormat * make()
Create a new IContainerFormat object.
static IContainerFormat * getInstalledInputFormat(int32_t index)
Return an object for the input format at the given index.
static IContainerFormat * getInstalledOutputFormat(int32_t index)
Return an object for the output format at the given index.
static int32_t getNumInstalledOutputFormats()
Get the number of output formats this install can multiplex (write) to.
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...