Skip to content

Commit 1a4d0cc

Browse files
committed
Split project into two crates mp4parse and mp4parse_capi (fixes #18)
1 parent 36827a7 commit 1a4d0cc

File tree

17 files changed

+71
-50
lines changed

17 files changed

+71
-50
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/target
2-
/Cargo.lock
1+
target
2+
Cargo.lock
33
*.o
44
libmp4parse.a*
55
mp4parse.d
66
examples/test
7-
include/mp4parse.h
7+
mp4parse_capi/include/mp4parse.h

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ env:
1515
- CXX=g++-5
1616

1717
script:
18-
- cargo build --verbose
19-
- cargo test --verbose
20-
- make -C examples
21-
- cargo doc
18+
- (cd mp4parse && cargo test --verbose)
19+
- (cd mp4parse_capi && cargo test --verbose)
20+
- make -C mp4parse_capi/examples
21+
- (cd mp4parse_capi && cargo doc)
2222

2323
deploy:
2424
provider: surge
25-
project: ./target/doc/
25+
project: ./mp4parse_capi/target/doc/
2626
domain: mp4parse-docs.surge.sh
2727
skip_cleanup: true

Cargo.toml renamed to mp4parse/Cargo.toml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mp4parse"
3-
version = "0.4.1"
3+
version = "0.5.0"
44
authors = [
55
"Ralph Giles <[email protected]>",
66
"Matthew Gregan <[email protected]>",
@@ -12,14 +12,6 @@ license = "MPL-2.0"
1212

1313
repository = "https://github.com/mozilla/mp4parse-rust"
1414

15-
# Cargo includes random files from the working directory
16-
# by default! Avoid bloating the package with test files.
17-
exclude = [
18-
"*.mp4",
19-
]
20-
21-
build = "build.rs"
22-
2315
[dependencies]
2416
byteorder = "0.5.0"
2517
afl = { version = "0.1.1", optional = true }
@@ -29,9 +21,6 @@ abort_on_panic = { version = "1.0.0", optional = true }
2921
[dev-dependencies]
3022
test-assembler = "0.1.2"
3123

32-
[build-dependencies]
33-
rusty-cheddar = "0.3.2"
34-
3524
[features]
3625
fuzz = ["afl", "afl-plugin", "abort_on_panic"]
3726

File renamed without changes.

src/lib.rs renamed to mp4parse/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ use byteorder::ReadBytesExt;
1313
use std::io::{Read, Take};
1414
use std::cmp;
1515

16-
// Expose C api wrapper.
17-
pub mod capi;
18-
pub use capi::*;
19-
2016
mod boxes;
2117
use boxes::BoxType;
2218

@@ -109,7 +105,7 @@ struct FileTypeBox {
109105
/// Movie header box 'mvhd'.
110106
#[derive(Debug)]
111107
struct MovieHeaderBox {
112-
timescale: u32,
108+
pub timescale: u32,
113109
duration: u64,
114110
}
115111

@@ -217,7 +213,7 @@ pub enum AudioCodecSpecific {
217213
#[derive(Debug, Clone)]
218214
pub struct AudioSampleEntry {
219215
data_reference_index: u16,
220-
channelcount: u16,
216+
pub channelcount: u16,
221217
pub samplesize: u16,
222218
pub samplerate: u32,
223219
pub codec_specific: AudioCodecSpecific,
@@ -318,7 +314,7 @@ pub struct Track {
318314
pub media_time: Option<TrackScaledTime>,
319315
pub timescale: Option<TrackTimeScale>,
320316
pub duration: Option<TrackScaledTime>,
321-
track_id: Option<u32>,
317+
pub track_id: Option<u32>,
322318
pub mime_type: String,
323319
pub data: Option<SampleEntry>,
324320
pub tkhd: Option<TrackHeaderBox>, // TODO(kinetik): find a nicer way to export this.
File renamed without changes.
File renamed without changes.

mp4parse_capi/Cargo.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[package]
2+
name = "mp4parse_capi"
3+
version = "0.5.0"
4+
authors = [
5+
"Ralph Giles <[email protected]>",
6+
"Matthew Gregan <[email protected]>",
7+
]
8+
9+
description = "Parser for ISO base media file format (mp4)"
10+
documentation = "https://mp4parse-docs.surge.sh/mp4parse/"
11+
license = "MPL-2.0"
12+
13+
repository = "https://github.com/mozilla/mp4parse-rust"
14+
15+
# Cargo includes random files from the working directory
16+
# by default! Avoid bloating the package with test files.
17+
exclude = [
18+
"*.mp4",
19+
]
20+
21+
build = "build.rs"
22+
23+
[dependencies]
24+
"mp4parse" = {path = "../mp4parse"}
25+
26+
[build-dependencies]
27+
rusty-cheddar = "0.3.2"
28+
29+
[features]
30+
fuzz = ["mp4parse/fuzz"]
31+
32+
# Somewhat heavy-handed, but we want at least -Z force-overflow-checks=on.
33+
[profile.release]
34+
debug-assertions = true

build.rs renamed to mp4parse_capi/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ extern crate cheddar;
33
fn main() {
44
// Generate mp4parse.h.
55
cheddar::Cheddar::new().expect("could not read manifest")
6-
.module("capi").expect("invalid module path")
76
.insert_code("// THIS FILE IS AUTOGENERATED BY mp4parse-rust/build.rs - DO NOT EDIT\n\n")
87
.insert_code("// This Source Code Form is subject to the terms of the Mozilla Public\n")
98
.insert_code("// License, v. 2.0. If a copy of the MPL was not distributed with this\n")
File renamed without changes.

examples/afl-capi.rs renamed to mp4parse_capi/examples/afl-capi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
extern crate mp4parse;
1+
extern crate mp4parse_capi;
22

3-
use mp4parse::*;
3+
use mp4parse_capi::*;
44

55
#[cfg(feature = "fuzz")]
66
#[macro_use]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

mp4parse_capi/lib.rs

Whitespace-only changes.

src/capi.rs renamed to mp4parse_capi/src/lib.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! # Examples
66
//!
77
//! ```rust
8-
//! extern crate mp4parse;
8+
//! extern crate mp4parse_capi;
99
//! use std::io::Read;
1010
//!
1111
//! extern fn buf_read(buf: *mut u8, size: usize, userdata: *mut std::os::raw::c_void) -> isize {
@@ -18,37 +18,40 @@
1818
//! }
1919
//!
2020
//! let mut file = std::fs::File::open("examples/minimal.mp4").unwrap();
21-
//! let io = mp4parse::mp4parse_io { read: buf_read,
22-
//! userdata: &mut file as *mut _ as *mut std::os::raw::c_void };
21+
//! let io = mp4parse_capi::mp4parse_io {
22+
//! read: buf_read,
23+
//! userdata: &mut file as *mut _ as *mut std::os::raw::c_void
24+
//! };
2325
//! unsafe {
24-
//! let parser = mp4parse::mp4parse_new(&io);
25-
//! let rv = mp4parse::mp4parse_read(parser);
26-
//! assert_eq!(rv, mp4parse::mp4parse_error::MP4PARSE_OK);
27-
//! mp4parse::mp4parse_free(parser);
26+
//! let parser = mp4parse_capi::mp4parse_new(&io);
27+
//! let rv = mp4parse_capi::mp4parse_read(parser);
28+
//! assert_eq!(rv, mp4parse_capi::mp4parse_error::MP4PARSE_OK);
29+
//! mp4parse_capi::mp4parse_free(parser);
2830
//! }
2931
//! ```
3032
3133
// This Source Code Form is subject to the terms of the Mozilla Public
3234
// License, v. 2.0. If a copy of the MPL was not distributed with this
3335
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
3436

35-
use std;
37+
extern crate mp4parse;
38+
3639
use std::io::Read;
3740
use std::collections::HashMap;
3841

3942
// Symbols we need from our rust api.
40-
use MediaContext;
41-
use TrackType;
42-
use read_mp4;
43-
use Error;
44-
use SampleEntry;
45-
use AudioCodecSpecific;
46-
use VideoCodecSpecific;
47-
use MediaTimeScale;
48-
use MediaScaledTime;
49-
use TrackTimeScale;
50-
use TrackScaledTime;
51-
use serialize_opus_header;
43+
use mp4parse::MediaContext;
44+
use mp4parse::TrackType;
45+
use mp4parse::read_mp4;
46+
use mp4parse::Error;
47+
use mp4parse::SampleEntry;
48+
use mp4parse::AudioCodecSpecific;
49+
use mp4parse::VideoCodecSpecific;
50+
use mp4parse::MediaTimeScale;
51+
use mp4parse::MediaScaledTime;
52+
use mp4parse::TrackTimeScale;
53+
use mp4parse::TrackScaledTime;
54+
use mp4parse::serialize_opus_header;
5255

5356
// rusty-cheddar's C enum generation doesn't namespace enum members by
5457
// prefixing them, so we're forced to do it in our member names until

0 commit comments

Comments
 (0)