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

Add CAMM atom and allow creating MP4 tracks with it. #7

Open
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions GNUmakefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ libmp4v2_la_SOURCES = \
src/atom_amr.cpp \
src/atom_avc1.cpp \
src/atom_avcC.cpp \
src/atom_camm.cpp \
src/atom_chpl.cpp \
src/atom_colr.cpp \
src/atom_d263.cpp \
Expand Down
42 changes: 42 additions & 0 deletions src/atom_camm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is MPEG4IP.
*
* The Initial Developer of the Original Code is Cisco Systems Inc.
* Portions created by Cisco Systems Inc. are
* Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved.
*
*/

#include "src/impl.h"

namespace mp4v2 {
namespace impl {

///////////////////////////////////////////////////////////////////////////////

MP4CammAtom::MP4CammAtom(MP4File &file)
: MP4Atom(file, "camm")
{
AddVersionAndFlags();

MP4Integer32Property* pCount =
new MP4Integer32Property(*this, "entryCount");
pCount->SetValue(1);
pCount->SetReadOnly();
AddProperty(pCount);
}

///////////////////////////////////////////////////////////////////////////////

}
} // namespace mp4v2::impl
9 changes: 9 additions & 0 deletions src/atoms.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ class MP4S263Atom : public MP4Atom {
* Specialized Atoms
************************************************************************/

class MP4CammAtom : public MP4Atom {
public:
MP4CammAtom(MP4File &file);
private:
MP4CammAtom();
MP4CammAtom( const MP4CammAtom &src );
MP4CammAtom &operator= ( const MP4CammAtom &src );
};

class MP4DrefAtom : public MP4Atom {
public:
MP4DrefAtom(MP4File &file);
Expand Down
2 changes: 2 additions & 0 deletions src/mp4atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,8 @@ MP4Atom::factory( MP4File &file, MP4Atom* parent, const char* type )
break;

case 'c':
if( ATOMID(type) == ATOMID("camm") )
return new MP4CammAtom(file);
if( ATOMID(type) == ATOMID("chap") )
return new MP4TrefTypeAtom( file, type );
if( ATOMID(type) == ATOMID("chpl") )
Expand Down
10 changes: 9 additions & 1 deletion src/mp4file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,11 @@ MP4TrackId MP4File::AddSystemsTrack(const char* type, uint32_t timeScale)

(void)InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "nmhd", 0);

(void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4s");
bool is_camm = strcmp(type, "camm") == 0;
const char *sample_entry = is_camm ? "camm" : "mp4s";

(void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"),
sample_entry);

AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.name");

Expand All @@ -1144,6 +1148,10 @@ MP4TrackId MP4File::AddSystemsTrack(const char* type, uint32_t timeScale)
(MP4Property**)&pStsdCountProperty);
pStsdCountProperty->IncrementValue();

if (is_camm) {
return trackId;
}

SetTrackIntegerProperty(trackId,
"mdia.minf.stbl.stsd.mp4s.esds.ESID",
0
Expand Down