Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sources build against newer Libav and FFmpeg libraries. #97

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions atom.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#include "AP_AtomDefinitions.h"
#include "atom.h"
#include "file.h"

#include <string>
#include <map>
#include <iostream>

#include <assert.h>
#include <endian.h>
#include <cassert>

using namespace std;

Expand Down
12 changes: 9 additions & 3 deletions atom.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#ifndef ATOM_H
#define ATOM_H
extern "C" {
#include <stdint.h>
}

#include <vector>
#include <string>
#if (__cplusplus >= 201103L)
# include <cstdint>
#else
extern "C" {
# include <stdint.h>
};
#endif

#include "file.h"

class Atom {
public:
int64_t start; //including 8 header bytes
Expand Down
3 changes: 1 addition & 2 deletions file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
*/

#include "file.h"
#include <string>
#include <endian.h>
#include "endian.h"

using namespace std;

Expand Down
12 changes: 8 additions & 4 deletions file.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
#ifndef FILE_H
#define FILE_H

extern "C" {
#include <stdint.h>
}
#include <stdio.h>
#include <vector>
#include <string>
#if (__cplusplus >= 201103L)
# include <cstdint>
#else
extern "C" {
# include <stdint.h>
};
#endif
#include <cstdio>

uint16_t swap16(uint16_t us);
uint32_t swap32(uint32_t ui);
Expand Down
34 changes: 27 additions & 7 deletions mp4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,36 @@

*/

#include <assert.h>
#include <string>
#include <iostream>
#include <cassert>

#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS 1
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS 1
#endif
#if (__cplusplus >= 201103L)
# include <cstdint>
#else
extern "C" {
# include <stdint.h>
};
#endif
#ifndef INT64_C
# define INT64_C(c) (c ## LL)
# define UINT64_C(c) (c ## ULL)
#endif

#define __STDC_LIMIT_MACROS 1
#define __STDC_CONSTANT_MACROS 1
extern "C" {
#include <stdint.h>
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#undef __bool_true_false_are_defined // Prevent #define of bool, true & false.
#define __bool_true_false_are_defined 1
#ifndef _Bool
# define _Bool bool
#endif

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}

#include "mp4.h"
Expand Down
2 changes: 1 addition & 1 deletion mp4.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

#include <vector>
#include <string>
#include <stdio.h>

#include "track.h"

class Atom;
class File;
class AVFormatContext;
Expand Down
70 changes: 39 additions & 31 deletions track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,59 @@

*/

#include "track.h"
#include "atom.h"

#include <iostream>
#include <vector>
#include <string.h>
#include <assert.h>
#include <endian.h>

#define __STDC_LIMIT_MACROS 1
#define __STDC_CONSTANT_MACROS 1
#include <cassert>

#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS 1
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS 1
#endif
#if (__cplusplus >= 201103L)
# include <cstdint>
#else
extern "C" {
# include <stdint.h>
};
#endif
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
# define INT64_C(c) (c ## LL)
# define UINT64_C(c) (c ## ULL)
#endif

extern "C" {
#undef __bool_true_false_are_defined // Prevent #define of bool, true & false.
#define __bool_true_false_are_defined 1
#ifndef _Bool
# define _Bool bool
#endif

#include <stdint.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>

//Horrible hack: there is a variabled named 'new' and 'class' inside!
#if LIBAVCODEC_VERSION_MAJOR != 56 //ubuntu 16.04 version
#include <config.h>
#undef restrict
//#define restrict __restrict__
// WARNING: Including internal header!
#if LIBAVCODEC_VERSION_MAJOR != 56 // Ubuntu 16.04 version.
# include <config.h>
#endif
// XXX Horrible Hack: Suppress C99 keywords that are not in C++, like 'restrict' and '_Atomic'! XXX
#undef restrict // Harmless; don't restrict memory access.
#define restrict
#define new extern_new
#define class extern_class
#undef _Atomic // Atomics are only included in headers, but never actually used in our code.
#define _Atomic
// XXX Horrible Hack: There are variables named 'new' and 'class' inside! XXX
#define new extern_new
#define class extern_class
#include <libavcodec/h264dec.h>
#undef new
#undef class
#undef new
#undef _Atomic
#undef restrict
}

#else
define new extern_new
#define class extern_class
#include <libavcodec/h264dec.h>
#undef new
#undef class
#endif
#include "track.h"
#include "atom.h"

}

using namespace std;

Expand Down Expand Up @@ -712,7 +720,7 @@ void Track::parse(Atom *t, Atom *mdat) {

if(!codec.codec) throw string("No codec found!");
if(avcodec_open2(codec.context, codec.codec, NULL)<0)
throw string("Could not open codec: ") + codec.context->codec_name;
throw string("Could not open codec: ") + codec.context->codec->name;


/*
Expand Down