Changeset 10


Ignore:
Timestamp:
07/19/10 11:51:05 (22 months ago)
Author:
shiretu
Message:

-- added defines at compile time to add/remove media file formats
-- svn:ignore stuff
-- fixed some errors on linux platform

Location:
trunk
Files:
16 added
140 edited

Legend:

Unmodified
Added
Removed
  • trunk/builders/androidapplestreaming

    • Property svn:ignore set to
      run
      bin
      gen
      libs

  • trunk/builders/androidapplestreaming/jni/Android.mk

    r9 r10  
    1717PROJDIR := $(PWD)/../.. 
    1818 
    19 PLATFORM_DEFINES := -DLITTLE_ENDIAN_BYTE_ALIGNED -DNET_SELECT -DANDROID -DHAS_PROTOCOL_HTTP 
     19PLATFORM_DEFINES := -DLITTLE_ENDIAN_BYTE_ALIGNED -DNET_SELECT -DANDROID 
    2020 
    21 MODULES_DEFINES := -DHAS_PROTOCOL_RTMP \ 
    22     -DHAS_PROTOCOL_LIVEFLV \ 
    23     -DHAS_PROTOCOL_RTP \ 
    24     -DHAS_PROTOCOL_TS \ 
    25     -DHAS_PROTOCOL_VAR 
     21MODULES_DEFINES :=  
     22MODULES_DEFINES += -DHAS_PROTOCOL_HTTP 
     23MODULES_DEFINES += -DHAS_PROTOCOL_RTP 
     24MODULES_DEFINES += -DHAS_PROTOCOL_TS 
     25MODULES_DEFINES += -DHAS_PROTOCOL_VAR 
     26#MODULES_DEFINES += -DHAS_PROTOCOL_RTMP 
     27#MODULES_DEFINES += -DHAS_PROTOCOL_LIVEFLV 
     28#MODULES_DEFINES += -DHAS_MEDIA_MP4 
     29#MODULES_DEFINES += -DHAS_MEDIA_MP3 
     30#MODULES_DEFINES += -DHAS_MEDIA_FLV 
    2631 
    2732GLOBAL_DEFINES := $(PLATFORM_DEFINES) $(MODULES_DEFINES) 
  • trunk/builders/cmake

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile

  • trunk/builders/cmake/CMakeLists.txt

    r2 r10  
    3636ADD_DEFINITIONS(-DHAS_PROTOCOL_VAR) 
    3737ADD_DEFINITIONS(-DHAS_LUA) 
     38ADD_DEFINITIONS(-DHAS_MEDIA_MP3) 
     39ADD_DEFINITIONS(-DHAS_MEDIA_MP4) 
     40ADD_DEFINITIONS(-DHAS_MEDIA_FLV) 
    3841 
    3942#memory pool 
  • trunk/builders/cmake/applications

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile

  • trunk/builders/cmake/applications/admin

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so

  • trunk/builders/cmake/applications/applestreamingclient

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so

  • trunk/builders/cmake/applications/appselector

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so

  • trunk/builders/cmake/applications/flvplayback

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so

  • trunk/builders/cmake/applications/proxypublish

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so

  • trunk/builders/cmake/applications/samplefactory

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so

  • trunk/builders/cmake/applications/stresstest

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so

  • trunk/builders/cmake/applications/vptests

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so


  • trunk/builders/cmake/common

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so
      *.gch

  • trunk/builders/cmake/lua

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so

  • trunk/builders/cmake/rtmpserver

    • Property svn:ignore set to
      MakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      rtmpserver

  • trunk/builders/cmake/tests

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      tests

  • trunk/builders/cmake/thelib

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so
      *.gch

  • trunk/builders/cmake/vm

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      *.dylib
      *.so

  • trunk/builders/cmake/vm/CMakeLists.txt

    r2 r10  
    2222ADD_LIBRARY(vm SHARED ${SOURCES}) 
    2323TARGET_LINK_LIBRARIES(vm lua common pthread ${EXECINFO_LIBRARY_PATH} ${OPENSSL_LIBRARY_PATH} ${CRYPTO_LIBRARY_PATH} ${V8_LIBRARY_PATH}) 
    24 ADD_PRECOMPILED_HEADER(vm ../../../sources/common/include/utils/core.h) 
    2524 
  • trunk/builders/cmake/vmtests

    • Property svn:ignore set to
      CMakeCache.txt
      cmake_install.cmake
      CMakeFiles
      Makefile
      vmtests

  • trunk/media

    • Property svn:ignore set to
      *.??
      *.???
      *.????
      good
      backup
      almost_good
  • trunk/sources/androidapplestreaming/src/api.cpp

    r7 r10  
    127127        IOHandlerManager::SignalShutdown(); 
    128128} 
     129 
     130Variant ContextCreate() { 
     131        return Variant(); 
     132} 
     133 
     134Variant ContextList() { 
     135        return Variant(); 
     136} 
     137 
     138Variant ContextClose(uint32_t contextId) { 
     139        return Variant(); 
     140} 
     141 
     142Variant ContextCloseAll() { 
     143        return Variant(); 
     144} 
     145 
     146Variant CommandPlay(uint32_t contextId, string m3u8Uri, string httpSessionId, 
     147                string keyPassword) { 
     148        return Variant(); 
     149} 
     150 
     151Variant CommandPause(uint32_t contextId) { 
     152        return Variant(); 
     153} 
     154 
     155Variant CommandResume(uint32_t contextId) { 
     156        return Variant(); 
     157} 
  • trunk/sources/applications/applestreamingclient/flex

    • Property svn:ignore set to
      bin-debug
      bin-release
      html-template
  • trunk/sources/applications/applestreamingclient/include/eventsink/rtmpeventsink.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_PROTOCOL_RTMP 
    2121#ifndef _RTMPEVENTSINK_H 
    2222#define _RTMPEVENTSINK_H 
     
    3939 
    4040#endif  /* _RTMPEVENTSINK_H */ 
    41  
     41#endif /* HAS_PROTOCOL_RTMP */ 
  • trunk/sources/applications/applestreamingclient/include/rtmpappprotocolhandler.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_PROTOCOL_RTMP 
    2121#ifndef _RTMPAPPPROTOCOLHANDLER_H 
    2222#define _RTMPAPPPROTOCOLHANDLER_H 
     
    4444 
    4545#endif  /* _RTMPAPPPROTOCOLHANDLER_H */ 
     46#endif /* HAS_PROTOCOL_RTMP */ 
  • trunk/sources/applications/applestreamingclient/src/eventsink/baseeventsink.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
    19  
    20  
    21  
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    2219 
    2320#include "eventsink/baseeventsink.h" 
     
    3431BaseEventSink * BaseEventSink::GetInstance(uint64_t type) { 
    3532        switch (type) { 
     33#ifdef HAS_PROTOCOL_RTMP 
    3634                case PT_INBOUND_RTMP: 
    3735                { 
    3836                        return new RTMPEventSink(); 
    3937                } 
     38#endif /* HAS_PROTOCOL_RTMP */ 
    4039                default: 
    4140                { 
  • trunk/sources/applications/applestreamingclient/src/eventsink/rtmpeventsink.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
    21  
    22  
     20#ifdef HAS_PROTOCOL_RTMP 
    2321#include "eventsink/rtmpeventsink.h" 
    2422#include "protocols/rtmp/basertmpprotocol.h" 
     
    6361        return true; 
    6462} 
     63#endif /* HAS_PROTOCOL_RTMP */ 
  • trunk/sources/applications/applestreamingclient/src/rtmpappprotocolhandler.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_PROTOCOL_RTMP 
    2121#include "utils/core.h" 
    2222#include "rtmpappprotocolhandler.h" 
     
    8989        return pContext->StartProcessing(); 
    9090} 
     91#endif /* HAS_PROTOCOL_RTMP */ 
  • trunk/sources/applications/flvplayback/flex

    • Property svn:ignore set to
      bin-debug
      bin-release
      html-template
  • trunk/sources/applications/misc_flash_resources/generic_flex_components

    • Property svn:ignore set to
      bin

  • trunk/sources/thelib/include/mediaformats/basemediadocument.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
    19  
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    2019 
    2120#ifndef _BASEMEDIADOCUMENT_H 
     
    3433protected: 
    3534#ifdef HAS_MMAP 
    36     MmapFile _mediaFile; 
     35        MmapFile _mediaFile; 
    3736#else 
    38     File _mediaFile; 
     37        File _mediaFile; 
    3938#endif /* HAS_MMAP */ 
    40     vector<MediaFrame> _frames; 
    41     uint32_t _audioSamplesCount; 
    42     uint32_t _videoSamplesCount; 
    43     Variant _metadata; 
    44     string _mediaFilePath; 
    45     string _seekFilePath; 
    46     string _metaFilePath; 
    47     bool _keyframeSeek; 
    48     uint32_t _seekGranularity; 
     39        vector<MediaFrame> _frames; 
     40        uint32_t _audioSamplesCount; 
     41        uint32_t _videoSamplesCount; 
     42        Variant _metadata; 
     43        string _mediaFilePath; 
     44        string _seekFilePath; 
     45        string _metaFilePath; 
     46        bool _keyframeSeek; 
     47        uint32_t _seekGranularity; 
    4948public: 
    50     BaseMediaDocument(Variant &metadata); 
    51     virtual ~BaseMediaDocument(); 
     49        BaseMediaDocument(Variant &metadata); 
     50        virtual ~BaseMediaDocument(); 
    5251 
    53     bool Process(); 
    54     Variant GetMetadata(); 
     52        bool Process(); 
     53        Variant GetMetadata(); 
    5554 
    5655protected: 
    57     static bool CompareFrames(const MediaFrame &frame1, const MediaFrame &frame2); 
    58     virtual bool ParseDocument() = 0; 
    59     virtual bool BuildFrames() = 0; 
    60     virtual Variant GetRTMPMeta() = 0; 
     56        static bool CompareFrames(const MediaFrame &frame1, const MediaFrame &frame2); 
     57        virtual bool ParseDocument() = 0; 
     58        virtual bool BuildFrames() = 0; 
     59        virtual Variant GetRTMPMeta() = 0; 
    6160private: 
    62     bool SaveSeekFile(); 
    63     bool SaveMetaFile(); 
     61        bool SaveSeekFile(); 
     62        bool SaveMetaFile(); 
    6463}; 
    6564 
     
    6766#endif  /* _BASEMEDIADOCUMENT_H */ 
    6867 
    69  
  • trunk/sources/thelib/include/mediaformats/flv/flvdocument.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_FLV 
    2121#ifndef _FLVDOCUMENT 
    2222#define _FLVDOCUMENT 
     
    2828: public BaseMediaDocument { 
    2929private: 
    30     uint32_t _audioSamplesCount; 
    31     uint32_t _videoSamplesCount; 
    32     Variant _metadata; 
     30        uint32_t _audioSamplesCount; 
     31        uint32_t _videoSamplesCount; 
     32        Variant _metadata; 
    3333public: 
    34     FLVDocument(Variant &metadata); 
    35     virtual ~FLVDocument(); 
     34        FLVDocument(Variant &metadata); 
     35        virtual ~FLVDocument(); 
    3636 
    3737protected: 
    38     virtual bool ParseDocument(); 
    39     virtual bool BuildFrames(); 
    40     virtual Variant GetRTMPMeta(); 
     38        virtual bool ParseDocument(); 
     39        virtual bool BuildFrames(); 
     40        virtual Variant GetRTMPMeta(); 
    4141}; 
    4242 
    43 #endif 
    44  
     43#endif /* _FLVDOCUMENT */ 
     44#endif /* HAS_MEDIA_FLV */ 
  • trunk/sources/thelib/include/mediaformats/mediaframe.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
    19  
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    2019 
    2120#ifndef _MEDIAFRAME_H 
     
    2928 
    3029typedef struct _MediaFrame { 
    31     uint64_t start; 
    32     uint64_t length; 
    33     uint8_t type; 
    34     double deltaTime; 
    35     bool isKeyFrame; 
    36     double absoluteTime; 
    37     bool isBinaryHeader; 
    38     int32_t compositionOffset; 
     30        uint64_t start; 
     31        uint64_t length; 
     32        uint8_t type; 
     33        double deltaTime; 
     34        bool isKeyFrame; 
     35        double absoluteTime; 
     36        bool isBinaryHeader; 
     37        int32_t compositionOffset; 
    3938 
    40     operator string() { 
    41         return format("s: %llx; l: %llx; t: %d; dt: %.2f; kf: %d; at: %.2f; bh: %d", 
    42                 start, length, type, deltaTime, isKeyFrame, absoluteTime, isBinaryHeader); 
    43     }; 
     39        operator string() { 
     40                return format("s: %llx; l: %llx; t: %d; dt: %.2f; kf: %d; at: %.2f; bh: %d", 
     41                                start, length, type, deltaTime, isKeyFrame, absoluteTime, isBinaryHeader); 
     42        }; 
    4443} MediaFrame; 
    4544 
    4645#endif  /* _MEDIAFRAME_H */ 
    4746 
    48  
  • trunk/sources/thelib/include/mediaformats/mp3/id3parser.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP3 
    2121#ifndef _ID3PARSER_H 
    2222#define _ID3PARSER_H 
     
    3232class ID3Parser { 
    3333protected: 
    34     bool _unsynchronisation; 
    35     bool _compression; 
    36     bool _extendedHeader; 
    37     bool _experimentalIndicator; 
    38     bool _footerPresent; 
    39     Variant _metadata; 
    40     uint32_t _majorVersion; 
    41     uint32_t _minorVersion; 
     34        bool _unsynchronisation; 
     35        bool _compression; 
     36        bool _extendedHeader; 
     37        bool _experimentalIndicator; 
     38        bool _footerPresent; 
     39        Variant _metadata; 
     40        uint32_t _majorVersion; 
     41        uint32_t _minorVersion; 
    4242public: 
    43     ID3Parser(uint32_t majorVersion, uint32_t minorVersion); 
    44     virtual ~ID3Parser(); 
     43        ID3Parser(uint32_t majorVersion, uint32_t minorVersion); 
     44        virtual ~ID3Parser(); 
    4545 
    46     Variant GetMetadata(); 
     46        Variant GetMetadata(); 
    4747#ifdef HAS_MMAP 
    48     bool Parse(MmapFile &file); 
     48        bool Parse(MmapFile &file); 
    4949#else 
    50     bool Parse(File &file); 
     50        bool Parse(File &file); 
    5151#endif /* HAS_MMAP */ 
    5252private: 
    53     bool ParseTags(IOBuffer &buffer); 
    54     bool ReadStringWithSize(IOBuffer &buffer, Variant &value, uint32_t size, bool hasEncoding); 
    55     bool ReadStringNullTerminated(IOBuffer &buffer, Variant &value, bool unicode); 
    56     bool ParseTextTag(IOBuffer &buffer, Variant &tag); 
    57     bool ParseUSLT(IOBuffer &buffer, Variant &tag); 
    58     bool ParseAPIC(IOBuffer &buffer, Variant &tag); 
    59     bool ParseCOMM(IOBuffer &buffer, Variant &tag); 
    60     bool ParseUrlTag(IOBuffer &buffer, Variant &tag); 
    61     bool ParseWXXX(IOBuffer &buffer, Variant &tag); 
    62     bool ParseTXXX(IOBuffer &buffer, Variant &tag); 
     53        bool ParseTags(IOBuffer &buffer); 
     54        bool ReadStringWithSize(IOBuffer &buffer, Variant &value, uint32_t size, bool hasEncoding); 
     55        bool ReadStringNullTerminated(IOBuffer &buffer, Variant &value, bool unicode); 
     56        bool ParseTextTag(IOBuffer &buffer, Variant &tag); 
     57        bool ParseUSLT(IOBuffer &buffer, Variant &tag); 
     58        bool ParseAPIC(IOBuffer &buffer, Variant &tag); 
     59        bool ParseCOMM(IOBuffer &buffer, Variant &tag); 
     60        bool ParseUrlTag(IOBuffer &buffer, Variant &tag); 
     61        bool ParseWXXX(IOBuffer &buffer, Variant &tag); 
     62        bool ParseTXXX(IOBuffer &buffer, Variant &tag); 
    6363}; 
    6464 
    6565 
    6666#endif  /* _ID3PARSER_H */ 
    67  
    68  
     67#endif /* HAS_MEDIA_MP3 */ 
  • trunk/sources/thelib/include/mediaformats/mp3/mp3document.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP3 
    2121#ifndef _MP3DOCUMENT_H 
    2222#define _MP3DOCUMENT_H 
     
    2828: public BaseMediaDocument { 
    2929private: 
    30     //ver/layer/bitRateIndex 
    31     static int32_t _bitRates[4][4][16]; 
    32     static int32_t _samplingRates[4][4]; 
    33     static string _versionNames[4]; 
    34     static string _layerNames[4]; 
    35     static map<uint8_t, map<uint8_t, map<uint8_t, map<uint8_t, map<uint8_t, uint64_t > > > > > _frameSizes; 
    36     Variant _tags; 
     30        //ver/layer/bitRateIndex 
     31        static int32_t _bitRates[4][4][16]; 
     32        static int32_t _samplingRates[4][4]; 
     33        static string _versionNames[4]; 
     34        static string _layerNames[4]; 
     35        static map<uint8_t, map<uint8_t, map<uint8_t, map<uint8_t, map<uint8_t, uint64_t > > > > > _frameSizes; 
     36        Variant _tags; 
    3737public: 
    38     MP3Document(Variant &metadata); 
    39     virtual ~MP3Document(); 
     38        MP3Document(Variant &metadata); 
     39        virtual ~MP3Document(); 
    4040protected: 
    41     virtual bool ParseDocument(); 
    42     virtual bool BuildFrames(); 
    43     virtual Variant GetRTMPMeta(); 
     41        virtual bool ParseDocument(); 
     42        virtual bool BuildFrames(); 
     43        virtual Variant GetRTMPMeta(); 
    4444private: 
    45     bool FindFrameData(); 
    46     bool ParseMetadata(); 
    47     void InitFrameSizes(); 
     45        bool FindFrameData(); 
     46        bool ParseMetadata(); 
     47        void InitFrameSizes(); 
    4848}; 
    4949 
    5050 
    51 #endif  /* _MP3DOCUMENT_H */ 
    52  
    53  
     51#endif /* _MP3DOCUMENT_H */ 
     52#endif /* HAS_MEDIA_MP3 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomavc1.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMAVC1_H 
    2222#define _ATOMAVC1_H 
     
    2929: public VersionedBoxAtom { 
    3030private: 
    31     AtomAVCC *_pAVCC; 
    32     uint16_t _reserved; 
    33     uint16_t _referenceIndex; 
    34     uint16_t _qtVideoEncodingVersion; 
    35     uint16_t _qtVideoEncodingRevisionLevel; 
    36     uint32_t _qtVideoEncodingVendor; 
    37     uint32_t _qtVideoTemporalQuality; 
    38     uint32_t _qtVideoSpatialQuality; 
    39     uint32_t _videoFramePixelSize; 
    40     uint32_t _horizontalDpi; 
    41     uint32_t _verticalDpi; 
    42     uint32_t _qtVideoDataSize; 
    43     uint16_t _videoFrameCount; 
    44     uint8_t _videoEncoderNameLength; 
    45     string _videoEncoderName; 
    46     uint16_t _videoPixelDepth; 
    47     uint16_t _qtVideoColorTableId; 
     31        AtomAVCC *_pAVCC; 
     32        uint16_t _reserved; 
     33        uint16_t _referenceIndex; 
     34        uint16_t _qtVideoEncodingVersion; 
     35        uint16_t _qtVideoEncodingRevisionLevel; 
     36        uint32_t _qtVideoEncodingVendor; 
     37        uint32_t _qtVideoTemporalQuality; 
     38        uint32_t _qtVideoSpatialQuality; 
     39        uint32_t _videoFramePixelSize; 
     40        uint32_t _horizontalDpi; 
     41        uint32_t _verticalDpi; 
     42        uint32_t _qtVideoDataSize; 
     43        uint16_t _videoFrameCount; 
     44        uint8_t _videoEncoderNameLength; 
     45        string _videoEncoderName; 
     46        uint16_t _videoPixelDepth; 
     47        uint16_t _qtVideoColorTableId; 
    4848public: 
    49     AtomAVC1(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    50     virtual ~AtomAVC1(); 
     49        AtomAVC1(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     50        virtual ~AtomAVC1(); 
    5151 
    5252protected: 
    53     virtual bool ReadData(); 
    54     virtual bool AtomCreated(BaseAtom *pAtom); 
     53        virtual bool ReadData(); 
     54        virtual bool AtomCreated(BaseAtom *pAtom); 
    5555}; 
    5656 
     
    5858 
    5959 
     60#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomavcc.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMAVCC_H 
    2222#define _ATOMAVCC_H 
     
    2525 
    2626typedef struct _AVCCParameter { 
    27     uint16_t size; 
    28     uint8_t *pData; 
     27        uint16_t size; 
     28        uint8_t *pData; 
    2929} AVCCParameter; 
    3030 
     
    3232: public BaseAtom { 
    3333private: 
    34     uint8_t _configurationVersion; 
    35     uint8_t _profile; 
    36     uint8_t _profileCompatibility; 
    37     uint8_t _level; 
    38     uint8_t _naluLengthSize; 
    39     vector<AVCCParameter> _seqParameters; 
    40     vector<AVCCParameter> _picParameters; 
     34        uint8_t _configurationVersion; 
     35        uint8_t _profile; 
     36        uint8_t _profileCompatibility; 
     37        uint8_t _level; 
     38        uint8_t _naluLengthSize; 
     39        vector<AVCCParameter> _seqParameters; 
     40        vector<AVCCParameter> _picParameters; 
    4141public: 
    42     AtomAVCC(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    43     virtual ~AtomAVCC(); 
    44     uint64_t GetExtraDataStart(); 
    45     uint64_t GetExtraDataLength(); 
    46     virtual bool Read(); 
    47     virtual string Hierarchy(uint32_t indent); 
     42        AtomAVCC(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     43        virtual ~AtomAVCC(); 
     44        uint64_t GetExtraDataStart(); 
     45        uint64_t GetExtraDataLength(); 
     46        virtual bool Read(); 
     47        virtual string Hierarchy(uint32_t indent); 
    4848}; 
    4949 
     
    5151 
    5252 
     53#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomco64.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMCO64_H 
    2222#define _ATOMCO64_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     vector<uint64_t> _entries; 
     29        vector<uint64_t> _entries; 
    3030public: 
    31     AtomCO64(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    32     virtual ~AtomCO64(); 
     31        AtomCO64(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     32        virtual ~AtomCO64(); 
    3333 
    34     vector<uint64_t> GetEntries(); 
     34        vector<uint64_t> GetEntries(); 
    3535protected: 
    36     virtual bool ReadData(); 
     36        virtual bool ReadData(); 
    3737}; 
    3838 
     
    4040 
    4141 
     42#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomctts.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMCTTS_H 
    2222#define _ATOMCTTS_H 
     
    2525 
    2626typedef struct _CTTSEntry { 
    27     uint32_t sampleCount; 
    28     int32_t sampleOffset; 
     27        uint32_t sampleCount; 
     28        int32_t sampleOffset; 
    2929} CTTSEntry; 
    3030 
     
    3232: public VersionedAtom { 
    3333private: 
    34     vector<CTTSEntry> _entries; 
    35     vector<int32_t> _normalizedEntries; 
     34        vector<CTTSEntry> _entries; 
     35        vector<int32_t> _normalizedEntries; 
    3636public: 
    37     AtomCTTS(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    38     virtual ~AtomCTTS(); 
    39     vector<int32_t> GetEntries(); 
     37        AtomCTTS(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     38        virtual ~AtomCTTS(); 
     39        vector<int32_t> GetEntries(); 
    4040protected: 
    41     virtual bool ReadData(); 
     41        virtual bool ReadData(); 
    4242}; 
    4343 
     
    4545 
    4646 
     47#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomdata.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMDATA_H 
    2222#define _ATOMDATA_H 
     
    2727: public BaseAtom { 
    2828private: 
    29     uint32_t _type; 
    30     uint32_t _unknown; 
     29        uint32_t _type; 
     30        uint32_t _unknown; 
    3131 
    32     string _dataString; 
    33     vector<uint16_t> _dataUI16; 
    34     vector<uint8_t> _dataUI8; 
    35     string _dataImg; 
     32        string _dataString; 
     33        vector<uint16_t> _dataUI16; 
     34        vector<uint8_t> _dataUI8; 
     35        string _dataImg; 
    3636public: 
    37     AtomDATA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    38     virtual ~AtomDATA(); 
     37        AtomDATA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     38        virtual ~AtomDATA(); 
    3939 
    40     Variant GetVariant(); 
     40        Variant GetVariant(); 
    4141 
    42     virtual bool Read(); 
    43     std::string Hierarchy(uint32_t indent); 
     42        virtual bool Read(); 
     43        std::string Hierarchy(uint32_t indent); 
    4444}; 
    4545 
     
    4747 
    4848 
     49#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomdinf.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMDINF_H 
    2222#define _ATOMDINF_H 
     
    2929: public BoxAtom { 
    3030private: 
    31     AtomDREF *_pDREF; 
     31        AtomDREF *_pDREF; 
    3232public: 
    33     AtomDINF(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    34     virtual ~AtomDINF(); 
     33        AtomDINF(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     34        virtual ~AtomDINF(); 
    3535protected: 
    36     virtual bool AtomCreated(BaseAtom *pAtom); 
     36        virtual bool AtomCreated(BaseAtom *pAtom); 
    3737}; 
    3838 
     
    4040 
    4141 
     42#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomdref.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMDREF_H 
    2222#define _ATOMDREF_H 
     
    2929: public VersionedBoxAtom { 
    3030private: 
    31     vector<AtomURL *> _urls; 
     31        vector<AtomURL *> _urls; 
    3232public: 
    33     AtomDREF(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    34     virtual ~AtomDREF(); 
     33        AtomDREF(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     34        virtual ~AtomDREF(); 
    3535 
    3636protected: 
    37     virtual bool ReadData(); 
    38     virtual bool AtomCreated(BaseAtom *pAtom); 
     37        virtual bool ReadData(); 
     38        virtual bool AtomCreated(BaseAtom *pAtom); 
    3939}; 
    4040 
     
    4242 
    4343 
     44#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomesds.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMESDS_H 
    2222#define _ATOMESDS_H 
     
    3535: public VersionedAtom { 
    3636private: 
    37     uint16_t _MP4ESDescrTag_ID; 
    38     uint8_t _MP4ESDescrTag_Priority; 
    39     uint8_t _MP4DecConfigDescrTag_ObjectTypeID; 
    40     uint8_t _MP4DecConfigDescrTag_StreamType; 
    41     uint32_t _MP4DecConfigDescrTag_BufferSizeDB; 
    42     uint32_t _MP4DecConfigDescrTag_MaxBitRate; 
    43     uint32_t _MP4DecConfigDescrTag_AvgBitRate; 
    44     uint64_t _extraDataStart; 
    45     uint64_t _extraDataLength; 
     37        uint16_t _MP4ESDescrTag_ID; 
     38        uint8_t _MP4ESDescrTag_Priority; 
     39        uint8_t _MP4DecConfigDescrTag_ObjectTypeID; 
     40        uint8_t _MP4DecConfigDescrTag_StreamType; 
     41        uint32_t _MP4DecConfigDescrTag_BufferSizeDB; 
     42        uint32_t _MP4DecConfigDescrTag_MaxBitRate; 
     43        uint32_t _MP4DecConfigDescrTag_AvgBitRate; 
     44        uint64_t _extraDataStart; 
     45        uint64_t _extraDataLength; 
    4646#ifdef DEBUG_ESDS_ATOM 
    47     uint8_t _objectType; 
    48     uint8_t _sampleRate; 
    49     uint8_t _channels; 
    50     uint8_t _extObjectType; 
    51     uint8_t _sbr; 
    52     uint8_t _extSampleRate; 
     47        uint8_t _objectType; 
     48        uint8_t _sampleRate; 
     49        uint8_t _channels; 
     50        uint8_t _extObjectType; 
     51        uint8_t _sbr; 
     52        uint8_t _extSampleRate; 
    5353#endif /* DEBUG_ESDS_ATOM */ 
    5454public: 
    55     AtomESDS(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    56     virtual ~AtomESDS(); 
    57     uint64_t GetExtraDataStart(); 
    58     uint64_t GetExtraDataLength(); 
     55        AtomESDS(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     56        virtual ~AtomESDS(); 
     57        uint64_t GetExtraDataStart(); 
     58        uint64_t GetExtraDataLength(); 
    5959protected: 
    60     virtual bool ReadData(); 
     60        virtual bool ReadData(); 
    6161private: 
    62     bool ReadTagLength(uint32_t &length); 
    63     bool ReadTagAndLength(uint8_t &tagType, uint32_t &length); 
     62        bool ReadTagLength(uint32_t &length); 
     63        bool ReadTagAndLength(uint8_t &tagType, uint32_t &length); 
    6464}; 
    6565 
     
    6767 
    6868 
     69#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomftyp.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMFTYP_H 
    2222#define _ATOMFTYP_H 
     
    2727: public BaseAtom { 
    2828private: 
    29     uint32_t _majorBrand; 
    30     uint32_t _minorVersion; 
    31     vector<uint32_t> _compatibleBrands; 
     29        uint32_t _majorBrand; 
     30        uint32_t _minorVersion; 
     31        vector<uint32_t> _compatibleBrands; 
    3232public: 
    33     AtomFTYP(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    34     virtual ~AtomFTYP(); 
     33        AtomFTYP(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     34        virtual ~AtomFTYP(); 
    3535 
    36     virtual bool Read(); 
     36        virtual bool Read(); 
    3737 
    38     virtual string Hierarchy(uint32_t indent); 
     38        virtual string Hierarchy(uint32_t indent); 
    3939}; 
    4040 
     
    4242 
    4343 
     44#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomhdlr.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMHDLR_H 
    2222#define _ATOMHDLR_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     uint32_t _componentType; 
    30     uint32_t _componentSubType; 
    31     uint32_t _componentManufacturer; 
    32     uint32_t _componentFlags; 
    33     uint32_t _componentFlagsMask; 
    34     string _componentName; 
     29        uint32_t _componentType; 
     30        uint32_t _componentSubType; 
     31        uint32_t _componentManufacturer; 
     32        uint32_t _componentFlags; 
     33        uint32_t _componentFlagsMask; 
     34        string _componentName; 
    3535public: 
    36     AtomHDLR(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    37     virtual ~AtomHDLR(); 
    38     uint32_t GetComponentSubType(); 
    39     virtual string Hierarchy(uint32_t indent); 
     36        AtomHDLR(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     37        virtual ~AtomHDLR(); 
     38        uint32_t GetComponentSubType(); 
     39        virtual string Hierarchy(uint32_t indent); 
    4040protected: 
    41     virtual bool ReadData(); 
     41        virtual bool ReadData(); 
    4242}; 
    4343 
     
    4545 
    4646 
     47#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomilst.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMILST_H 
    2222#define _ATOMILST_H 
     
    2929: public BoxAtom { 
    3030private: 
    31     vector<AtomMetaField *> _metaFields; 
     31        vector<AtomMetaField *> _metaFields; 
    3232public: 
    33     AtomILST(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    34     virtual ~AtomILST(); 
     33        AtomILST(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     34        virtual ~AtomILST(); 
    3535 
    36     Variant GetVariant(); 
     36        Variant GetVariant(); 
    3737 
    3838protected: 
    39     virtual bool AtomCreated(BaseAtom *pAtom); 
     39        virtual bool AtomCreated(BaseAtom *pAtom); 
    4040}; 
    4141 
     
    4343 
    4444 
     45#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atommdhd.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMMDHD_H 
    2222#define _ATOMMDHD_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     uint32_t _creationTime; 
    30     uint32_t _modificationTime; 
    31     uint32_t _timeScale; 
    32     uint32_t _duration; 
    33     uint16_t _language; 
    34     uint16_t _quality; 
     29        uint32_t _creationTime; 
     30        uint32_t _modificationTime; 
     31        uint32_t _timeScale; 
     32        uint32_t _duration; 
     33        uint16_t _language; 
     34        uint16_t _quality; 
    3535public: 
    36     AtomMDHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    37     virtual ~AtomMDHD(); 
     36        AtomMDHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     37        virtual ~AtomMDHD(); 
    3838 
    39     uint32_t GetTimeScale(); 
    40     uint32_t GetDuration(); 
     39        uint32_t GetTimeScale(); 
     40        uint32_t GetDuration(); 
    4141protected: 
    42     virtual bool ReadData(); 
     42        virtual bool ReadData(); 
    4343}; 
    4444 
     
    4646 
    4747 
     48#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atommdia.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMMDIA_H 
    2222#define _ATOMMDIA_H 
     
    3333: public BoxAtom { 
    3434private: 
    35     AtomMDHD *_pMDHD; 
    36     AtomHDLR *_pHDLR; 
    37     AtomMINF *_pMINF; 
    38     AtomDINF *_pDINF; 
    39     AtomSTBL *_pSTBL; 
     35        AtomMDHD *_pMDHD; 
     36        AtomHDLR *_pHDLR; 
     37        AtomMINF *_pMINF; 
     38        AtomDINF *_pDINF; 
     39        AtomSTBL *_pSTBL; 
    4040public: 
    41     AtomMDIA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    42     virtual ~AtomMDIA(); 
     41        AtomMDIA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     42        virtual ~AtomMDIA(); 
    4343 
    4444protected: 
    45     virtual bool AtomCreated(BaseAtom *pAtom); 
     45        virtual bool AtomCreated(BaseAtom *pAtom); 
    4646}; 
    4747 
     
    4949 
    5050 
     51#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atommeta.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMMETA_H 
    2222#define _ATOMMETA_H 
     
    3030: public VersionedBoxAtom { 
    3131private: 
    32     AtomHDLR *_pHDLR; 
    33     AtomILST *_pILST; 
     32        AtomHDLR *_pHDLR; 
     33        AtomILST *_pILST; 
    3434public: 
    35     AtomMETA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    36     virtual ~AtomMETA(); 
     35        AtomMETA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     36        virtual ~AtomMETA(); 
    3737 
    38     virtual bool Read(); 
     38        virtual bool Read(); 
    3939 
    4040protected: 
    41     virtual bool ReadData(); 
    42     virtual bool AtomCreated(BaseAtom *pAtom); 
     41        virtual bool ReadData(); 
     42        virtual bool AtomCreated(BaseAtom *pAtom); 
    4343}; 
    4444 
     
    4646 
    4747 
     48#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atommetafield.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMMETAFIELD_H 
    2222#define _ATOMMETAFIELD_H 
     
    2929: public BoxAtom { 
    3030private: 
    31     AtomDATA *_pDATA; 
    32     string _stringData; 
     31        AtomDATA *_pDATA; 
     32        string _stringData; 
    3333public: 
    34     AtomMetaField(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    35     virtual ~AtomMetaField(); 
     34        AtomMetaField(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     35        virtual ~AtomMetaField(); 
    3636 
    37     Variant GetVariant(); 
    38     virtual bool Read(); 
     37        Variant GetVariant(); 
     38        virtual bool Read(); 
    3939protected: 
    40     virtual bool AtomCreated(BaseAtom *pAtom); 
     40        virtual bool AtomCreated(BaseAtom *pAtom); 
    4141}; 
    4242 
     
    4444 
    4545 
     46#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomminf.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMMINF_H 
    2222#define _ATOMMINF_H 
     
    3333: public BoxAtom { 
    3434private: 
    35     AtomSMHD *_pSMHD; 
    36     AtomDINF *_pDINF; 
    37     AtomSTBL *_pSTBL; 
    38     AtomVMHD *_pVMHD; 
    39     AtomHDLR *_pHDLR; 
     35        AtomSMHD *_pSMHD; 
     36        AtomDINF *_pDINF; 
     37        AtomSTBL *_pSTBL; 
     38        AtomVMHD *_pVMHD; 
     39        AtomHDLR *_pHDLR; 
    4040public: 
    41     AtomMINF(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    42     virtual ~AtomMINF(); 
     41        AtomMINF(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     42        virtual ~AtomMINF(); 
    4343 
    4444protected: 
    45     virtual bool AtomCreated(BaseAtom *pAtom); 
     45        virtual bool AtomCreated(BaseAtom *pAtom); 
    4646}; 
    4747 
     
    4949 
    5050 
     51#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atommoov.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMMOOV_H 
    2222#define _ATOMMOOV_H 
     
    3333: public BoxAtom { 
    3434private: 
    35     AtomMVHD *_pMVHD; 
    36     vector<AtomTRAK *> _tracks; 
    37     AtomUDTA *_pUDTA; 
    38     AtomMETA *_pMETA; 
     35        AtomMVHD *_pMVHD; 
     36        vector<AtomTRAK *> _tracks; 
     37        AtomUDTA *_pUDTA; 
     38        AtomMETA *_pMETA; 
    3939public: 
    40     AtomMOOV(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    41     virtual ~AtomMOOV(); 
     40        AtomMOOV(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     41        virtual ~AtomMOOV(); 
    4242 
    43     vector<AtomTRAK *> GetTracks(); 
     43        vector<AtomTRAK *> GetTracks(); 
    4444protected: 
    45     virtual bool AtomCreated(BaseAtom *pAtom); 
     45        virtual bool AtomCreated(BaseAtom *pAtom); 
    4646}; 
    4747 
     
    4949 
    5050 
     51#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atommp4a.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMMP4A_H 
    2222#define _ATOMMP4A_H 
     
    3131: public VersionedBoxAtom { 
    3232protected: 
    33     AtomESDS *_pESDS; 
    34     AtomWAVE *_pWAVE; 
    35     AtomCHAN *_pCHAN; 
    36     uint16_t _dataReferenceIndex; 
    37     uint16_t _innerVersion; 
    38     uint16_t _revisionLevel; 
    39     uint32_t _vendor; 
    40     uint16_t _numberOfChannels; 
    41     uint16_t _sampleSizeInBits; 
    42     int16_t _compressionId; 
    43     uint16_t _packetSize; 
    44     uint32_t _sampleRate; 
    45     uint32_t _samplesPerPacket; 
    46     uint32_t _bytesPerPacket; 
    47     uint32_t _bytesPerFrame; 
    48     uint32_t _bytesPerSample; 
     33        AtomESDS *_pESDS; 
     34        AtomWAVE *_pWAVE; 
     35        AtomCHAN *_pCHAN; 
     36        uint16_t _dataReferenceIndex; 
     37        uint16_t _innerVersion; 
     38        uint16_t _revisionLevel; 
     39        uint32_t _vendor; 
     40        uint16_t _numberOfChannels; 
     41        uint16_t _sampleSizeInBits; 
     42        int16_t _compressionId; 
     43        uint16_t _packetSize; 
     44        uint32_t _sampleRate; 
     45        uint32_t _samplesPerPacket; 
     46        uint32_t _bytesPerPacket; 
     47        uint32_t _bytesPerFrame; 
     48        uint32_t _bytesPerSample; 
    4949public: 
    50     AtomMP4A(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    51     virtual ~AtomMP4A(); 
     50        AtomMP4A(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     51        virtual ~AtomMP4A(); 
    5252 
    5353 
    5454protected: 
    55     virtual bool ReadData(); 
    56     virtual bool AtomCreated(BaseAtom *pAtom); 
     55        virtual bool ReadData(); 
     56        virtual bool AtomCreated(BaseAtom *pAtom); 
    5757}; 
    5858 
     
    6060 
    6161 
     62#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atommvhd.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMMVHD_H 
    2222#define _ATOMMVHD_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     uint32_t _creationTime; 
    30     uint32_t _modificationTime; 
    31     uint32_t _timeScale; 
    32     uint32_t _duration; 
    33     uint32_t _preferredRate; 
    34     uint16_t _preferredVolume; 
    35     uint8_t _reserved[10]; 
    36     uint32_t _matrixStructure[9]; 
    37     uint32_t _previewTime; 
    38     uint32_t _previewDuration; 
    39     uint32_t _posterTime; 
    40     uint32_t _selectionTime; 
    41     uint32_t _selectionDuration; 
    42     uint32_t _currentTime; 
    43     uint32_t _nextTrakId; 
     29        uint32_t _creationTime; 
     30        uint32_t _modificationTime; 
     31        uint32_t _timeScale; 
     32        uint32_t _duration; 
     33        uint32_t _preferredRate; 
     34        uint16_t _preferredVolume; 
     35        uint8_t _reserved[10]; 
     36        uint32_t _matrixStructure[9]; 
     37        uint32_t _previewTime; 
     38        uint32_t _previewDuration; 
     39        uint32_t _posterTime; 
     40        uint32_t _selectionTime; 
     41        uint32_t _selectionDuration; 
     42        uint32_t _currentTime; 
     43        uint32_t _nextTrakId; 
    4444public: 
    45     AtomMVHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    46     virtual ~AtomMVHD(); 
     45        AtomMVHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     46        virtual ~AtomMVHD(); 
    4747 
    4848protected: 
    49     virtual bool ReadData(); 
     49        virtual bool ReadData(); 
    5050}; 
    5151 
     
    5353 
    5454 
     55#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomnull.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMNULL_H 
    2222#define _ATOMNULL_H 
     
    2727: public BaseAtom { 
    2828public: 
    29     AtomNULL(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    30     virtual ~AtomNULL(); 
     29        AtomNULL(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     30        virtual ~AtomNULL(); 
    3131 
    32     virtual bool IsIgnored(); 
     32        virtual bool IsIgnored(); 
    3333 
    34     virtual bool Read(); 
    35     string Hierarchy(uint32_t indent); 
     34        virtual bool Read(); 
     35        string Hierarchy(uint32_t indent); 
    3636}; 
    3737 
     
    3939 
    4040 
     41#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomsmhd.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMSMHD_H 
    2222#define _ATOMSMHD_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     uint16_t _balance; 
    30     uint16_t _reserved; 
     29        uint16_t _balance; 
     30        uint16_t _reserved; 
    3131public: 
    32     AtomSMHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    33     virtual ~AtomSMHD(); 
     32        AtomSMHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     33        virtual ~AtomSMHD(); 
    3434 
    3535protected: 
    36     virtual bool ReadData(); 
     36        virtual bool ReadData(); 
    3737}; 
    3838 
     
    4040 
    4141 
     42#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomstbl.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMSTBL_H 
    2222#define _ATOMSTBL_H 
     
    3636: public BoxAtom { 
    3737private: 
    38     AtomSTSD *_pSTSD; 
    39     AtomSTTS *_pSTTS; 
    40     AtomSTSC *_pSTSC; 
    41     AtomSTSZ *_pSTSZ; 
    42     AtomSTCO *_pSTCO; 
    43     AtomCO64 *_pCO64; 
    44     AtomCTTS *_pCTTS; 
    45     AtomSTSS *_pSTSS; 
     38        AtomSTSD *_pSTSD; 
     39        AtomSTTS *_pSTTS; 
     40        AtomSTSC *_pSTSC; 
     41        AtomSTSZ *_pSTSZ; 
     42        AtomSTCO *_pSTCO; 
     43        AtomCO64 *_pCO64; 
     44        AtomCTTS *_pCTTS; 
     45        AtomSTSS *_pSTSS; 
    4646public: 
    47     AtomSTBL(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    48     virtual ~AtomSTBL(); 
     47        AtomSTBL(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     48        virtual ~AtomSTBL(); 
    4949 
    5050 
    5151protected: 
    52     virtual bool AtomCreated(BaseAtom *pAtom); 
     52        virtual bool AtomCreated(BaseAtom *pAtom); 
    5353}; 
    5454 
     
    5656 
    5757 
     58#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomstco.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMSTCO_H 
    2222#define _ATOMSTCO_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     vector<uint64_t> _entries; 
     29        vector<uint64_t> _entries; 
    3030public: 
    31     AtomSTCO(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    32     virtual ~AtomSTCO(); 
     31        AtomSTCO(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     32        virtual ~AtomSTCO(); 
    3333 
    34     vector<uint64_t> GetEntries(); 
     34        vector<uint64_t> GetEntries(); 
    3535protected: 
    36     virtual bool ReadData(); 
     36        virtual bool ReadData(); 
    3737}; 
    3838 
     
    4040 
    4141 
     42#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomstsc.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMSTSC_H 
    2222#define _ATOMSTSC_H 
     
    2525 
    2626typedef struct _STSCEntry { 
    27     uint32_t firstChunk; 
    28     uint32_t samplesPerChunk; 
    29     uint32_t sampleDescriptionIndex; 
     27        uint32_t firstChunk; 
     28        uint32_t samplesPerChunk; 
     29        uint32_t sampleDescriptionIndex; 
    3030} STSCEntry; 
    3131 
     
    3333: public VersionedAtom { 
    3434private: 
    35     vector<STSCEntry> _stscEntries; 
     35        vector<STSCEntry> _stscEntries; 
    3636 
    37     //map<sampleId, chunkId> 
    38     vector<uint32_t> _normalizedEntries; 
     37        //map<sampleId, chunkId> 
     38        vector<uint32_t> _normalizedEntries; 
    3939public: 
    40     AtomSTSC(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    41     virtual ~AtomSTSC(); 
     40        AtomSTSC(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     41        virtual ~AtomSTSC(); 
    4242 
    43     vector<uint32_t> GetEntries(uint32_t totalChunksCount); 
     43        vector<uint32_t> GetEntries(uint32_t totalChunksCount); 
    4444protected: 
    45     virtual bool ReadData(); 
     45        virtual bool ReadData(); 
    4646}; 
    4747 
     
    4949 
    5050 
     51#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomstsd.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMSTSD_H 
    2222#define _ATOMSTSD_H 
     
    3030: public VersionedBoxAtom { 
    3131private: 
    32     AtomAVC1 *_pAVC1; 
    33     AtomMP4A *_pMP4A; 
     32        AtomAVC1 *_pAVC1; 
     33        AtomMP4A *_pMP4A; 
    3434public: 
    35     AtomSTSD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    36     virtual ~AtomSTSD(); 
     35        AtomSTSD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     36        virtual ~AtomSTSD(); 
    3737 
    3838 
    3939protected: 
    40     virtual bool ReadData(); 
    41     virtual bool AtomCreated(BaseAtom *pAtom); 
     40        virtual bool ReadData(); 
     41        virtual bool AtomCreated(BaseAtom *pAtom); 
    4242}; 
    4343 
     
    4545 
    4646 
     47#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomstss.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMSTSS_H 
    2222#define _ATOMSTSS_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     vector<uint32_t> _entries; 
     29        vector<uint32_t> _entries; 
    3030public: 
    31     AtomSTSS(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    32     virtual ~AtomSTSS(); 
     31        AtomSTSS(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     32        virtual ~AtomSTSS(); 
    3333 
    34     vector<uint32_t> GetEntries(); 
     34        vector<uint32_t> GetEntries(); 
    3535protected: 
    36     virtual bool ReadData(); 
     36        virtual bool ReadData(); 
    3737}; 
    3838 
     
    4040 
    4141 
     42#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomstsz.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMSTSZ_H 
    2222#define _ATOMSTSZ_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     uint32_t _sampleSize; 
    30     uint32_t _sampleCount; 
    31     vector<uint64_t> _entries; 
     29        uint32_t _sampleSize; 
     30        uint32_t _sampleCount; 
     31        vector<uint64_t> _entries; 
    3232public: 
    33     AtomSTSZ(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    34     virtual ~AtomSTSZ(); 
     33        AtomSTSZ(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     34        virtual ~AtomSTSZ(); 
    3535 
    36     vector<uint64_t> GetEntries(); 
     36        vector<uint64_t> GetEntries(); 
    3737protected: 
    38     virtual bool ReadData(); 
     38        virtual bool ReadData(); 
    3939}; 
    4040 
     
    4242 
    4343 
     44#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomstts.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMSTTS_H 
    2222#define _ATOMSTTS_H 
     
    2525 
    2626typedef struct _STTSEntry { 
    27     uint32_t count; 
    28     uint32_t delta; 
     27        uint32_t count; 
     28        uint32_t delta; 
    2929} STTSEntry; 
    3030 
     
    3232: public VersionedAtom { 
    3333private: 
    34     vector<STTSEntry> _sttsEntries; 
    35     vector<uint32_t> _normalizedEntries; 
     34        vector<STTSEntry> _sttsEntries; 
     35        vector<uint32_t> _normalizedEntries; 
    3636public: 
    37     AtomSTTS(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    38     virtual ~AtomSTTS(); 
     37        AtomSTTS(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     38        virtual ~AtomSTTS(); 
    3939 
    40     vector<uint32_t> GetEntries(); 
     40        vector<uint32_t> GetEntries(); 
    4141protected: 
    42     virtual bool ReadData(); 
     42        virtual bool ReadData(); 
    4343}; 
    4444 
     
    4646 
    4747 
     48#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomtkhd.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMTKHD_H 
    2222#define _ATOMTKHD_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     uint32_t _creationTime; 
    30     uint32_t _modificationTime; 
    31     uint32_t _trackId; 
    32     uint8_t _reserved1[4]; 
    33     uint32_t _duration; 
    34     uint8_t _reserved2[8]; 
    35     uint16_t _layer; 
    36     uint16_t _alternateGroup; 
    37     uint16_t _volume; 
    38     uint8_t _reserved3[2]; 
    39     uint8_t _matrixStructure[36]; 
    40     uint32_t _trackWidth; 
    41     uint32_t _trackHeight; 
     29        uint32_t _creationTime; 
     30        uint32_t _modificationTime; 
     31        uint32_t _trackId; 
     32        uint8_t _reserved1[4]; 
     33        uint32_t _duration; 
     34        uint8_t _reserved2[8]; 
     35        uint16_t _layer; 
     36        uint16_t _alternateGroup; 
     37        uint16_t _volume; 
     38        uint8_t _reserved3[2]; 
     39        uint8_t _matrixStructure[36]; 
     40        uint32_t _trackWidth; 
     41        uint32_t _trackHeight; 
    4242public: 
    43     AtomTKHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    44     virtual ~AtomTKHD(); 
     43        AtomTKHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     44        virtual ~AtomTKHD(); 
    4545 
    46     uint32_t GetWidth(); 
    47     uint32_t GetHeight(); 
     46        uint32_t GetWidth(); 
     47        uint32_t GetHeight(); 
    4848protected: 
    49     virtual bool ReadData(); 
     49        virtual bool ReadData(); 
    5050}; 
    5151 
     
    5353 
    5454 
     55#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomtrak.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMTRAK_H 
    2222#define _ATOMTRAK_H 
     
    3636: public BoxAtom { 
    3737private: 
    38     AtomTKHD *_pTKHD; 
    39     AtomMDIA *_pMDIA; 
    40     AtomHDLR *_pHDLR; 
    41     AtomMINF *_pMINF; 
    42     AtomDINF *_pDINF; 
    43     AtomSTBL *_pSTBL; 
    44     AtomUDTA *_pUDTA; 
    45     AtomMETA *_pMETA; 
     38        AtomTKHD *_pTKHD; 
     39        AtomMDIA *_pMDIA; 
     40        AtomHDLR *_pHDLR; 
     41        AtomMINF *_pMINF; 
     42        AtomDINF *_pDINF; 
     43        AtomSTBL *_pSTBL; 
     44        AtomUDTA *_pUDTA; 
     45        AtomMETA *_pMETA; 
    4646public: 
    47     AtomTRAK(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    48     virtual ~AtomTRAK(); 
     47        AtomTRAK(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     48        virtual ~AtomTRAK(); 
    4949 
    5050protected: 
    51     virtual bool AtomCreated(BaseAtom *pAtom); 
     51        virtual bool AtomCreated(BaseAtom *pAtom); 
    5252}; 
    5353 
     
    5555 
    5656 
     57#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomudta.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMUDTA_H 
    2222#define _ATOMUDTA_H 
     
    3030: public BoxAtom { 
    3131private: 
    32     AtomMETA *_pMETA; 
    33     vector<AtomMetaField *> _metaFields; 
     32        AtomMETA *_pMETA; 
     33        vector<AtomMetaField *> _metaFields; 
    3434public: 
    35     AtomUDTA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    36     virtual ~AtomUDTA(); 
     35        AtomUDTA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     36        virtual ~AtomUDTA(); 
    3737 
    38     virtual bool Read(); 
     38        virtual bool Read(); 
    3939 
    4040protected: 
    41     virtual bool AtomCreated(BaseAtom *pAtom); 
     41        virtual bool AtomCreated(BaseAtom *pAtom); 
    4242}; 
    4343 
     
    4545 
    4646 
     47#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomurl.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMURL_H 
    2222#define _ATOMURL_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     string _location; 
     29        string _location; 
    3030public: 
    31     AtomURL(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    32     virtual ~AtomURL(); 
     31        AtomURL(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     32        virtual ~AtomURL(); 
    3333protected: 
    34     virtual bool ReadData(); 
     34        virtual bool ReadData(); 
    3535}; 
    3636 
     
    3838 
    3939 
     40#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomvmhd.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMVMHD_H 
    2222#define _ATOMVMHD_H 
     
    2727: public VersionedAtom { 
    2828private: 
    29     uint16_t _graphicsMode; 
    30     uint8_t _opcolor[6]; 
     29        uint16_t _graphicsMode; 
     30        uint8_t _opcolor[6]; 
    3131public: 
    32     AtomVMHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    33     virtual ~AtomVMHD(); 
     32        AtomVMHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     33        virtual ~AtomVMHD(); 
    3434protected: 
    35     virtual bool ReadData(); 
     35        virtual bool ReadData(); 
    3636}; 
    3737 
     
    3939 
    4040 
     41#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/atomwave.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _ATOMWAVE_H 
    2222#define _ATOMWAVE_H 
     
    3030: public BoxAtom { 
    3131private: 
    32     AtomMP4A *_pMP4A; 
    33     AtomESDS *_pESDS; 
     32        AtomMP4A *_pMP4A; 
     33        AtomESDS *_pESDS; 
    3434public: 
    35     AtomWAVE(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    36     virtual ~AtomWAVE(); 
     35        AtomWAVE(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     36        virtual ~AtomWAVE(); 
    3737 
    38     virtual bool AtomCreated(BaseAtom *pAtom); 
     38        virtual bool AtomCreated(BaseAtom *pAtom); 
    3939}; 
    4040 
     
    4242 
    4343 
     44#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/baseatom.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _BASEATOM_H 
    2222#define _BASEATOM_H 
     
    3030class BaseAtom { 
    3131protected: 
    32     uint64_t _start; 
    33     uint64_t _size; 
     32        uint64_t _start; 
     33        uint64_t _size; 
    3434 
    35     uint32_t _type; 
     35        uint32_t _type; 
    3636 
    37     MP4Document *_pDoc; 
    38     BaseAtom *_pParent; 
     37        MP4Document *_pDoc; 
     38        BaseAtom *_pParent; 
    3939public: 
    40     BaseAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    41     virtual ~BaseAtom(); 
     40        BaseAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     41        virtual ~BaseAtom(); 
    4242 
    43     uint64_t GetStart(); 
    44     uint64_t GetSize(); 
    45     string GetTypeString(); 
    46     uint32_t GetTypeNumeric(); 
     43        uint64_t GetStart(); 
     44        uint64_t GetSize(); 
     45        string GetTypeString(); 
     46        uint32_t GetTypeNumeric(); 
    4747 
    48     MP4Document * GetDoc(); 
     48        MP4Document * GetDoc(); 
    4949 
    50     virtual bool Read() = 0; 
     50        virtual bool Read() = 0; 
    5151 
    52     virtual operator string(); 
    53     virtual bool IsIgnored(); 
     52        virtual operator string(); 
     53        virtual bool IsIgnored(); 
    5454 
    55     virtual BaseAtom * GetPath(vector<uint32_t> path); 
     55        virtual BaseAtom * GetPath(vector<uint32_t> path); 
    5656 
    57     virtual string Hierarchy(uint32_t indent) = 0; 
     57        virtual string Hierarchy(uint32_t indent) = 0; 
    5858 
    59     BaseAtom *GetParentAtom(); 
    60     void SetParentAtom(BaseAtom *pParent); 
     59        BaseAtom *GetParentAtom(); 
     60        void SetParentAtom(BaseAtom *pParent); 
    6161 
    6262protected: 
    63     bool SkipRead(bool issueWarn = true); 
    64     uint64_t CurrentPosition(); 
    65     bool CheckBounds(uint64_t size); 
    66     bool ReadArray(uint8_t *pBuffer, uint64_t length); 
    67     bool ReadUInt8(uint8_t &val); 
    68     bool ReadUInt16(uint16_t &val, bool networkOrder = true); 
    69     bool ReadInt16(int16_t &val, bool networkOrder = true); 
    70     bool ReadUInt24(uint32_t &val, bool networkOrder = true); 
    71     bool ReadUInt32(uint32_t &val, bool networkOrder = true); 
    72     bool ReadInt32(int32_t &val, bool networkOrder = true); 
    73     bool ReadUInt64(uint64_t &val, bool networkOrder = true); 
    74     bool ReadInt64(int64_t &val, bool networkOrder = true); 
    75     bool SkipBytes(uint64_t count); 
    76     bool ReadString(string &val, uint64_t size); 
     63        bool SkipRead(bool issueWarn = true); 
     64        uint64_t CurrentPosition(); 
     65        bool CheckBounds(uint64_t size); 
     66        bool ReadArray(uint8_t *pBuffer, uint64_t length); 
     67        bool ReadUInt8(uint8_t &val); 
     68        bool ReadUInt16(uint16_t &val, bool networkOrder = true); 
     69        bool ReadInt16(int16_t &val, bool networkOrder = true); 
     70        bool ReadUInt24(uint32_t &val, bool networkOrder = true); 
     71        bool ReadUInt32(uint32_t &val, bool networkOrder = true); 
     72        bool ReadInt32(int32_t &val, bool networkOrder = true); 
     73        bool ReadUInt64(uint64_t &val, bool networkOrder = true); 
     74        bool ReadInt64(int64_t &val, bool networkOrder = true); 
     75        bool SkipBytes(uint64_t count); 
     76        bool ReadString(string &val, uint64_t size); 
    7777}; 
    7878 
     
    8080 
    8181 
     82#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/boxatom.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _BOXATOM_H 
    2222#define _BOXATOM_H 
     
    2727: public BaseAtom { 
    2828private: 
    29     vector<BaseAtom *> _subAtoms; 
     29        vector<BaseAtom *> _subAtoms; 
    3030public: 
    31     BoxAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    32     virtual ~BoxAtom(); 
     31        BoxAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     32        virtual ~BoxAtom(); 
    3333 
    34     virtual bool Read(); 
    35     virtual string Hierarchy(uint32_t indent); 
     34        virtual bool Read(); 
     35        virtual string Hierarchy(uint32_t indent); 
    3636 
    37     BaseAtom * GetPath(uint8_t depth, ...); 
    38     virtual BaseAtom * GetPath(vector<uint32_t> path); 
     37        BaseAtom * GetPath(uint8_t depth, ...); 
     38        virtual BaseAtom * GetPath(vector<uint32_t> path); 
    3939protected: 
    40     virtual bool AtomCreated(BaseAtom *pAtom) = 0; 
     40        virtual bool AtomCreated(BaseAtom *pAtom) = 0; 
    4141}; 
    4242 
     
    4545 
    4646 
     47#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/ignoredatom.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _IGNOREDATOM_H 
    2222#define _IGNOREDATOM_H 
     
    2727: public BaseAtom { 
    2828public: 
    29     IgnoredAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    30     virtual ~IgnoredAtom(); 
     29        IgnoredAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     30        virtual ~IgnoredAtom(); 
    3131 
    32     virtual bool IsIgnored(); 
     32        virtual bool IsIgnored(); 
    3333 
    34     virtual bool Read(); 
    35     virtual string Hierarchy(uint32_t indent); 
     34        virtual bool Read(); 
     35        virtual string Hierarchy(uint32_t indent); 
    3636}; 
    3737 
     
    3939 
    4040 
     41#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/mp4document.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _MP4DOCUMENT_H 
    2222#define _MP4DOCUMENT_H 
     
    110110: public BaseMediaDocument { 
    111111private: 
    112     vector<BaseAtom *> _allAtoms; 
    113     vector<BaseAtom *> _topAtoms; 
    114     AtomFTYP *_pFTYP; 
    115     AtomMOOV *_pMOOV; 
     112        vector<BaseAtom *> _allAtoms; 
     113        vector<BaseAtom *> _topAtoms; 
     114        AtomFTYP *_pFTYP; 
     115        AtomMOOV *_pMOOV; 
    116116public: 
    117     MP4Document(Variant &metadata); 
    118     virtual ~MP4Document(); 
     117        MP4Document(Variant &metadata); 
     118        virtual ~MP4Document(); 
    119119 
    120120#ifdef HAS_MMAP 
    121     MmapFile &GetMediaFile(); 
     121        MmapFile &GetMediaFile(); 
    122122#else 
    123     File &GetMediaFile(); 
     123        File &GetMediaFile(); 
    124124#endif /* HAS_MMAP */ 
    125     void AddAtom(BaseAtom *pAtom); 
    126     BaseAtom * ReadAtom(BaseAtom *pParentAtom); 
     125        void AddAtom(BaseAtom *pAtom); 
     126        BaseAtom * ReadAtom(BaseAtom *pParentAtom); 
    127127protected: 
    128     virtual bool ParseDocument(); 
    129     virtual bool BuildFrames(); 
    130     virtual Variant GetRTMPMeta(); 
     128        virtual bool ParseDocument(); 
     129        virtual bool BuildFrames(); 
     130        virtual Variant GetRTMPMeta(); 
    131131private: 
    132     string Hierarchy(); 
    133     AtomTRAK * GetTRAK(bool audio); 
    134     bool BuildFrames(bool audio); 
     132        string Hierarchy(); 
     133        AtomTRAK * GetTRAK(bool audio); 
     134        bool BuildFrames(bool audio); 
    135135}; 
    136136 
     
    138138 
    139139 
     140#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/versionedatom.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _VERSIONEDATOM_H 
    2222#define _VERSIONEDATOM_H 
     
    2727: public BaseAtom { 
    2828private: 
    29     uint8_t _version; 
    30     uint8_t _flags[3]; 
     29        uint8_t _version; 
     30        uint8_t _flags[3]; 
    3131public: 
    32     VersionedAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    33     virtual ~VersionedAtom(); 
    34     bool Read(); 
    35     virtual string Hierarchy(uint32_t indent); 
     32        VersionedAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     33        virtual ~VersionedAtom(); 
     34        bool Read(); 
     35        virtual string Hierarchy(uint32_t indent); 
    3636protected: 
    37     virtual bool ReadData() = 0; 
     37        virtual bool ReadData() = 0; 
    3838}; 
    3939 
     
    4141 
    4242 
     43#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/mediaformats/mp4/versionedboxatom.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#ifndef _VERSIONEDBOXATOM_H 
    2222#define _VERSIONEDBOXATOM_H 
     
    2828: public BoxAtom { 
    2929protected: 
    30     uint8_t _version; 
    31     uint8_t _flags[3]; 
     30        uint8_t _version; 
     31        uint8_t _flags[3]; 
    3232public: 
    33     VersionedBoxAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
    34     virtual ~VersionedBoxAtom(); 
     33        VersionedBoxAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start); 
     34        virtual ~VersionedBoxAtom(); 
    3535protected: 
    36     virtual bool Read(); 
    37     virtual bool ReadData() = 0; 
     36        virtual bool Read(); 
     37        virtual bool ReadData() = 0; 
    3838}; 
    3939 
     
    4242 
    4343 
     44#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/include/streaming/baseinfilestream.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    3939private: 
    4040 
    41     class InFileStreamTimer 
    42     : public BaseTimerProtocol { 
    43     private: 
    44         BaseInFileStream *_pInFileStream; 
    45     public: 
    46         InFileStreamTimer(BaseInFileStream *pInFileStream); 
    47         virtual ~InFileStreamTimer(); 
    48         void ResetStream(); 
    49         virtual bool TimePeriodElapsed(); 
    50     }; 
    51     friend class InFileStreamTimer; 
     41        class InFileStreamTimer 
     42        : public BaseTimerProtocol { 
     43        private: 
     44                BaseInFileStream *_pInFileStream; 
     45        public: 
     46                InFileStreamTimer(BaseInFileStream *pInFileStream); 
     47                virtual ~InFileStreamTimer(); 
     48                void ResetStream(); 
     49                virtual bool TimePeriodElapsed(); 
     50        }; 
     51        friend class InFileStreamTimer; 
    5252#ifndef HAS_MMAP 
    53     static map<string, pair<uint32_t, File *> > _fileCache; 
     53        static map<string, pair<uint32_t, File *> > _fileCache; 
    5454#endif /* HAS_MMAP */ 
    5555 
    56     InFileStreamTimer *_pTimer; 
     56        InFileStreamTimer *_pTimer; 
    5757 
    58     FileClass *_pSeekFile; 
    59     FileClass *_pFile; 
     58        FileClass *_pSeekFile; 
     59        FileClass *_pFile; 
    6060 
    61     //frame info 
    62     uint32_t _totalFrames; 
    63     uint32_t _currentFrameIndex; 
    64     MediaFrame _currentFrame; 
     61        //frame info 
     62        uint32_t _totalFrames; 
     63        uint32_t _currentFrameIndex; 
     64        MediaFrame _currentFrame; 
    6565 
    66     //timing info 
    67     uint32_t _totalSentTime; 
    68     uint32_t _totalSentTimeBase; 
    69     time_t _startFeedingTime; 
     66        //timing info 
     67        uint32_t _totalSentTime; 
     68        uint32_t _totalSentTimeBase; 
     69        time_t _startFeedingTime; 
    7070 
    71     //buffering info 
    72     int32_t _clientSideBufferLength; 
    73     IOBuffer _videoBuffer; 
    74     IOBuffer _audioBuffer; 
     71        //buffering info 
     72        int32_t _clientSideBufferLength; 
     73        IOBuffer _videoBuffer; 
     74        IOBuffer _audioBuffer; 
    7575 
    76     //current state info 
    77     bool _paused; 
     76        //current state info 
     77        bool _paused; 
    7878public: 
    79     BaseInFileStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
    80             uint64_t type, string name); 
    81     virtual ~BaseInFileStream(); 
     79        BaseInFileStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
     80                        uint64_t type, string name); 
     81        virtual ~BaseInFileStream(); 
    8282 
    83     /* 
    84     * Returns the stream capabilities. Specifically, codec and codec related info 
    85     * */ 
    86     virtual StreamCapabilities * GetCapabilities(); 
     83        /* 
     84        * Returns the stream capabilities. Specifically, codec and codec related info 
     85        * */ 
     86        virtual StreamCapabilities * GetCapabilities(); 
    8787 
    88     /* 
    89     * Extracts the complete metadata from partial metadata 
    90     * metaData - the partial metadata containing at least the media file name 
    91     * */ 
    92     static bool ResolveCompleteMetadata(Variant &metaData); 
     88        /* 
     89        * Extracts the complete metadata from partial metadata 
     90        * metaData - the partial metadata containing at least the media file name 
     91        * */ 
     92        static bool ResolveCompleteMetadata(Variant &metaData); 
    9393 
    94     /* 
    95     * This will initialize the stream internally. 
    96     * clientSideBufferLength - the client side buffer length expressed in seconds 
    97     * */ 
    98     bool Initialize(int32_t clientSideBufferLength); 
     94        /* 
     95        * This will initialize the stream internally. 
     96        * clientSideBufferLength - the client side buffer length expressed in seconds 
     97        * */ 
     98        bool Initialize(int32_t clientSideBufferLength); 
    9999 
    100     /* 
    101     * Called when a play command was issued 
    102     * absoluteTimestamp - the timestamp where we want to seek 
    103     *                     before start the feeding process 
    104     * */ 
    105     virtual bool SignalPlay(double &absoluteTimestamp, double &length); 
     100        /* 
     101        * Called when a play command was issued 
     102        * absoluteTimestamp - the timestamp where we want to seek 
     103        *                     before start the feeding process 
     104        * */ 
     105        virtual bool SignalPlay(double &absoluteTimestamp, double &length); 
    106106 
    107     /* 
    108     * Called when a pasue command was issued 
    109     * */ 
    110     virtual bool SignalPause(); 
     107        /* 
     108        * Called when a pasue command was issued 
     109        * */ 
     110        virtual bool SignalPause(); 
    111111 
    112     /* 
    113     * Called when a resume command was issued 
    114     * */ 
    115     virtual bool SignalResume(); 
     112        /* 
     113        * Called when a resume command was issued 
     114        * */ 
     115        virtual bool SignalResume(); 
    116116 
    117     /* 
    118     * Called when a seek command was issued 
    119     * absoluteTimestamp - the 
    120     * */ 
    121     virtual bool SignalSeek(double &absoluteTimestamp); 
     117        /* 
     118        * Called when a seek command was issued 
     119        * absoluteTimestamp - the 
     120        * */ 
     121        virtual bool SignalSeek(double &absoluteTimestamp); 
    122122 
    123     /* 
    124     * Called when a stop command was issued 
    125     * */ 
    126     virtual bool SignalStop(); 
     123        /* 
     124        * Called when a stop command was issued 
     125        * */ 
     126        virtual bool SignalStop(); 
    127127 
    128     /* 
    129     * This is called by the framework. The networking layer signaled the 
    130     * availability for sending data 
    131     * */ 
    132     virtual void ReadyForSend(); 
     128        /* 
     129        * This is called by the framework. The networking layer signaled the 
     130        * availability for sending data 
     131        * */ 
     132        virtual void ReadyForSend(); 
    133133 
    134134protected: 
    135     virtual bool BuildFrame(FileClass *pFile, MediaFrame &mediaFrame, 
    136             IOBuffer &buffer) = 0; 
     135        virtual bool BuildFrame(FileClass *pFile, MediaFrame &mediaFrame, 
     136                        IOBuffer &buffer) = 0; 
    137137private: 
    138     /* 
    139     * This will seek to the specified point in time. 
    140     * absoluteTimestamp - the timestamp where we want to seek 
    141     *                     before start the feeding process 
    142     * */ 
    143     bool InternalSeek(double &absoluteTimestamp); 
     138        /* 
     139        * This will seek to the specified point in time. 
     140        * absoluteTimestamp - the timestamp where we want to seek 
     141        *                     before start the feeding process 
     142        * */ 
     143        bool InternalSeek(double &absoluteTimestamp); 
    144144 
    145     /* 
    146     * This is the function that will actually do the feeding. 
    147     * It is called by the framework and it must deliver one frame at a time 
    148     * to all subscribers 
    149     * */ 
    150     virtual bool Feed(); 
     145        /* 
     146        * This is the function that will actually do the feeding. 
     147        * It is called by the framework and it must deliver one frame at a time 
     148        * to all subscribers 
     149        * */ 
     150        virtual bool Feed(); 
    151151 
    152     /* 
    153     * GetFile function will open a file and will cache it if is a regular file. 
    154     * If the file is mmap based file, it will NOT cache it 
    155     * ReleaseFile will do the opposite: It will close the file if the references 
    156     * count will reach 0. This always happens in case of mmap file 
    157     * */ 
     152        /* 
     153        * GetFile function will open a file and will cache it if is a regular file. 
     154        * If the file is mmap based file, it will NOT cache it 
     155        * ReleaseFile will do the opposite: It will close the file if the references 
     156        * count will reach 0. This always happens in case of mmap file 
     157        * */ 
    158158#ifdef HAS_MMAP 
    159     static MmapFile* GetFile(string filePath, uint32_t windowSize); 
    160     static void ReleaseFile(MmapFile *pFile); 
     159        static MmapFile* GetFile(string filePath, uint32_t windowSize); 
     160        static void ReleaseFile(MmapFile *pFile); 
    161161#else 
    162     static File* GetFile(string filePath, uint32_t windowSize); 
    163     static void ReleaseFile(File *pFile); 
     162        static File* GetFile(string filePath, uint32_t windowSize); 
     163        static void ReleaseFile(File *pFile); 
    164164#endif /* HAS_MMAP */ 
    165165}; 
  • trunk/sources/thelib/include/streaming/baseinnetstream.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2727: public BaseInStream { 
    2828public: 
    29     BaseInNetStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
    30             uint64_t type, string name); 
    31     virtual ~BaseInNetStream(); 
     29        BaseInNetStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
     30                        uint64_t type, string name); 
     31        virtual ~BaseInNetStream(); 
    3232}; 
    3333 
  • trunk/sources/thelib/include/streaming/baseinstream.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2929: public BaseStream { 
    3030private: 
    31     bool _canCallOutStreamDetached; 
     31        bool _canCallOutStreamDetached; 
    3232protected: 
    33     map<uint32_t, BaseOutStream *> _linkedStreams; 
    34     LinkedListNode<BaseOutStream *> *_pOutStreams; 
     33        map<uint32_t, BaseOutStream *> _linkedStreams; 
     34        LinkedListNode<BaseOutStream *> *_pOutStreams; 
    3535public: 
    36     BaseInStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
    37             uint64_t type, string name); 
    38     virtual ~BaseInStream(); 
     36        BaseInStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
     37                        uint64_t type, string name); 
     38        virtual ~BaseInStream(); 
    3939 
    4040        vector<BaseOutStream *> GetOutStreams(); 
    4141 
    42     /* 
    43     * pOutStream - the out-stream to be linked to this in stream. 
    44     * reverseLink - if true, pOutStream::Link will be called internally 
    45     *               this is used to break the infinite calls. 
    46     * */ 
    47     virtual bool Link(BaseOutStream *pOutStream, bool reverseLink = true); 
     42        /* 
     43        * pOutStream - the out-stream to be linked to this in stream. 
     44        * reverseLink - if true, pOutStream::Link will be called internally 
     45        *               this is used to break the infinite calls. 
     46        * */ 
     47        virtual bool Link(BaseOutStream *pOutStream, bool reverseLink = true); 
    4848 
    49     /* 
    50     * pOutStream - the out-stream to be unlinked from this in stream. 
    51     * reverseUnLink - if true, pOutStream::UnLink will be called internally 
    52     *               this is used to break the infinite calls 
    53     * */ 
    54     virtual bool UnLink(BaseOutStream *pOutStream, bool reverseUnLink = true); 
     49        /* 
     50        * pOutStream - the out-stream to be unlinked from this in stream. 
     51        * reverseUnLink - if true, pOutStream::UnLink will be called internally 
     52        *               this is used to break the infinite calls 
     53        * */ 
     54        virtual bool UnLink(BaseOutStream *pOutStream, bool reverseUnLink = true); 
    5555 
    56     /* 
    57     * This will start the feeding process 
    58     * absoluteTimestamp - the timestamp where we want to seek 
    59     *                     before start the feeding process 
    60     * */ 
    61     virtual bool Play(double absoluteTimestamp, double length); 
     56        /* 
     57        * This will start the feeding process 
     58        * absoluteTimestamp - the timestamp where we want to seek 
     59        *                     before start the feeding process 
     60        * */ 
     61        virtual bool Play(double absoluteTimestamp, double length); 
    6262 
    63     /* 
    64     * This will pause the feeding process 
    65     * */ 
    66     virtual bool Pause(); 
     63        /* 
     64        * This will pause the feeding process 
     65        * */ 
     66        virtual bool Pause(); 
    6767 
    68     /* 
    69     * This will resume the feeding process 
    70     * */ 
    71     virtual bool Resume(); 
     68        /* 
     69        * This will resume the feeding process 
     70        * */ 
     71        virtual bool Resume(); 
    7272 
    73     /* 
    74     * This will seek to the specified point in time. 
    75     * */ 
    76     virtual bool Seek(double absoluteTimestamp); 
     73        /* 
     74        * This will seek to the specified point in time. 
     75        * */ 
     76        virtual bool Seek(double absoluteTimestamp); 
    7777 
    78     /* 
    79     * This will stop the feeding process 
    80     * */ 
    81     virtual bool Stop(); 
     78        /* 
     79        * This will stop the feeding process 
     80        * */ 
     81        virtual bool Stop(); 
    8282 
    83     /* 
    84     * Called after the link is complete 
    85     * pOutStream - the newly added stream 
    86     * */ 
    87     virtual void SignalOutStreamAttached(BaseOutStream *pOutStream) = 0; 
     83        /* 
     84        * Called after the link is complete 
     85        * pOutStream - the newly added stream 
     86        * */ 
     87        virtual void SignalOutStreamAttached(BaseOutStream *pOutStream) = 0; 
    8888 
    89     /* 
    90     * Called after the link is broken 
    91     * pOutStream - the removed stream 
    92     * */ 
    93     virtual void SignalOutStreamDetached(BaseOutStream *pOutStream) = 0; 
     89        /* 
     90        * Called after the link is broken 
     91        * pOutStream - the removed stream 
     92        * */ 
     93        virtual void SignalOutStreamDetached(BaseOutStream *pOutStream) = 0; 
    9494}; 
    9595 
  • trunk/sources/thelib/include/streaming/baseoutfilestream.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2727: public BaseOutStream { 
    2828public: 
    29     BaseOutFileStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
    30             uint64_t type, string name); 
    31     virtual ~BaseOutFileStream(); 
     29        BaseOutFileStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
     30                        uint64_t type, string name); 
     31        virtual ~BaseOutFileStream(); 
    3232}; 
    3333 
  • trunk/sources/thelib/include/streaming/baseoutnetstream.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2727: public BaseOutStream { 
    2828public: 
    29     BaseOutNetStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
    30             uint64_t type, string name); 
    31     virtual ~BaseOutNetStream(); 
     29        BaseOutNetStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
     30                        uint64_t type, string name); 
     31        virtual ~BaseOutNetStream(); 
    3232}; 
    3333 
  • trunk/sources/thelib/include/streaming/baseoutstream.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2929: public BaseStream { 
    3030private: 
    31     bool _canCallDetachedFromInStream; 
     31        bool _canCallDetachedFromInStream; 
    3232protected: 
    33     BaseInStream *_pInStream; 
     33        BaseInStream *_pInStream; 
    3434public: 
    35     BaseOutStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
    36             uint64_t type, string name); 
    37     virtual ~BaseOutStream(); 
     35        BaseOutStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
     36                        uint64_t type, string name); 
     37        virtual ~BaseOutStream(); 
    3838 
    39     /* 
    40     * Returns the stream capabilities. Specifically, codec and codec related info 
    41     * */ 
    42     virtual StreamCapabilities * GetCapabilities(); 
     39        /* 
     40        * Returns the stream capabilities. Specifically, codec and codec related info 
     41        * */ 
     42        virtual StreamCapabilities * GetCapabilities(); 
    4343 
    44     /* 
    45     * The networking layer signaled the availability for sending data 
    46     * */ 
    47     virtual void ReadyForSend(); 
     44        /* 
     45        * The networking layer signaled the availability for sending data 
     46        * */ 
     47        virtual void ReadyForSend(); 
    4848 
    49     /* 
    50     * pInStream - the in-stream where we want to attach 
    51     * reverseLink - if true, pInStream::Link will be called internally 
    52     *               this is used to break the infinite calls. 
    53     * */ 
    54     virtual bool Link(BaseInStream *pInStream, bool reverseLink = true); 
     49        /* 
     50        * pInStream - the in-stream where we want to attach 
     51        * reverseLink - if true, pInStream::Link will be called internally 
     52        *               this is used to break the infinite calls. 
     53        * */ 
     54        virtual bool Link(BaseInStream *pInStream, bool reverseLink = true); 
    5555 
    56     /* 
    57     * reverseUnLink - if true, pInStream::UnLink will be called internally 
    58     *               this is used to break the infinite calls 
    59     * */ 
    60     virtual bool UnLink(bool reverseUnLink = true); 
     56        /* 
     57        * reverseUnLink - if true, pInStream::UnLink will be called internally 
     58        *               this is used to break the infinite calls 
     59        * */ 
     60        virtual bool UnLink(bool reverseUnLink = true); 
    6161 
    62     /* 
    63     * Returns true if this stream is linked to an inbound stream. Otherwise 
    64     * returns false 
    65     * */ 
    66     bool IsLinked(); 
     62        /* 
     63        * Returns true if this stream is linked to an inbound stream. Otherwise 
     64        * returns false 
     65        * */ 
     66        bool IsLinked(); 
    6767 
    68     /* 
    69     * Returns the feder of this stream 
    70     * */ 
    71     BaseInStream *GetInStream(); 
     68        /* 
     69        * Returns the feder of this stream 
     70        * */ 
     71        BaseInStream *GetInStream(); 
    7272 
    73     /* 
    74     * This will start the feeding process 
    75     * absoluteTimestamp - the timestamp where we want to seek 
    76     *                     before start the feeding process 
    77     * */ 
    78     virtual bool Play(double absoluteTimestamp, double length); 
     73        /* 
     74        * This will start the feeding process 
     75        * absoluteTimestamp - the timestamp where we want to seek 
     76        *                     before start the feeding process 
     77        * */ 
     78        virtual bool Play(double absoluteTimestamp, double length); 
    7979 
    80     /* 
    81     * This will pause the feeding process 
    82     * */ 
    83     virtual bool Pause(); 
     80        /* 
     81        * This will pause the feeding process 
     82        * */ 
     83        virtual bool Pause(); 
    8484 
    85     /* 
    86     * This will resume the feeding process 
    87     * */ 
    88     virtual bool Resume(); 
     85        /* 
     86        * This will resume the feeding process 
     87        * */ 
     88        virtual bool Resume(); 
    8989 
    90     /* 
    91     * This will seek to the specified point in time. 
    92     * */ 
    93     virtual bool Seek(double absoluteTimestamp); 
     90        /* 
     91        * This will seek to the specified point in time. 
     92        * */ 
     93        virtual bool Seek(double absoluteTimestamp); 
    9494 
    95     /* 
    96     * This will stop the feeding process 
    97     * */ 
    98     virtual bool Stop(); 
     95        /* 
     96        * This will stop the feeding process 
     97        * */ 
     98        virtual bool Stop(); 
    9999 
    100     /* 
    101     * Called after the link is complete 
    102     * */ 
    103     virtual void SignalAttachedToInStream() = 0; 
     100        /* 
     101        * Called after the link is complete 
     102        * */ 
     103        virtual void SignalAttachedToInStream() = 0; 
    104104 
    105     /* 
    106     * Called after the link is broken 
    107     * */ 
    108     virtual void SignalDetachedFromInStream() = 0; 
     105        /* 
     106        * Called after the link is broken 
     107        * */ 
     108        virtual void SignalDetachedFromInStream() = 0; 
    109109 
    110     /* 
    111     * Called when the feeder finished the work 
    112     * */ 
    113     virtual void SignalStreamCompleted() = 0; 
     110        /* 
     111        * Called when the feeder finished the work 
     112        * */ 
     113        virtual void SignalStreamCompleted() = 0; 
    114114}; 
    115115 
  • trunk/sources/thelib/include/streaming/basestream.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    3030class DLLEXP BaseStream { 
    3131protected: 
    32     StreamsManager *_pStreamsManager; 
    33     uint64_t _type; 
    34     uint32_t _uniqueId; 
    35     BaseProtocol *_pProtocol; 
    36     string _name; 
     32        StreamsManager *_pStreamsManager; 
     33        uint64_t _type; 
     34        uint32_t _uniqueId; 
     35        BaseProtocol *_pProtocol; 
     36        string _name; 
    3737public: 
    38     BaseStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
    39             uint64_t type, string name); 
    40     virtual ~BaseStream(); 
     38        BaseStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
     39                        uint64_t type, string name); 
     40        virtual ~BaseStream(); 
    4141 
    42     /* 
    43     * Returns the stream manager. This is read-only 
    44     * */ 
    45     StreamsManager * GetStreamsManager(); 
     42        /* 
     43        * Returns the stream manager. This is read-only 
     44        * */ 
     45        StreamsManager * GetStreamsManager(); 
    4646 
    47     /* 
    48     * Returns the stream capabilities. Specifically, codec and codec related info 
    49     * */ 
    50     virtual StreamCapabilities * GetCapabilities() = 0; 
     47        /* 
     48        * Returns the stream capabilities. Specifically, codec and codec related info 
     49        * */ 
     50        virtual StreamCapabilities * GetCapabilities() = 0; 
    5151 
    52     /* 
    53     * Returns the type of this stream. This is read-only 
    54     * */ 
    55     uint64_t GetType(); 
     52        /* 
     53        * Returns the type of this stream. This is read-only 
     54        * */ 
     55        uint64_t GetType(); 
    5656 
    57     /* 
    58     * Returns the unique id of this stream. This is read-only 
    59     * */ 
    60     uint32_t GetUniqueId(); 
     57        /* 
     58        * Returns the unique id of this stream. This is read-only 
     59        * */ 
     60        uint32_t GetUniqueId(); 
    6161 
    62     /* 
    63     * Returns the name of this stream. This is setup-once 
    64     * */ 
    65     string GetName(); 
    66     void SetName(string name); 
     62        /* 
     63        * Returns the name of this stream. This is setup-once 
     64        * */ 
     65        string GetName(); 
     66        void SetName(string name); 
    6767 
    68     /* 
    69     * Returns the protocol that owns this stream. 
    70     * */ 
    71     BaseProtocol * GetProtocol(); 
     68        /* 
     69        * Returns the protocol that owns this stream. 
     70        * */ 
     71        BaseProtocol * GetProtocol(); 
    7272 
    73     /* 
    74     * Tells if this stream is enqueued for delete or not based on the pProtocol 
    75     * */ 
    76     virtual bool IsEnqueueForDelete(); 
     73        /* 
     74        * Tells if this stream is enqueued for delete or not based on the pProtocol 
     75        * */ 
     76        virtual bool IsEnqueueForDelete(); 
    7777 
    78     /* 
    79     * Will enqueue this stream for delete along with his protocol 
    80     * */ 
    81     virtual void EnqueueForDelete(); 
     78        /* 
     79        * Will enqueue this stream for delete along with his protocol 
     80        * */ 
     81        virtual void EnqueueForDelete(); 
    8282 
    83     /* 
    84     * This will start the feeding process 
    85     * absoluteTimestamp - the timestamp where we want to seek 
    86     *                     before start the feeding process 
    87     * length - time limit 
    88     * */ 
    89     virtual bool Play(double absoluteTimestamp, double length) = 0; 
     83        /* 
     84        * This will start the feeding process 
     85        * absoluteTimestamp - the timestamp where we want to seek 
     86        *                     before start the feeding process 
     87        * length - time limit 
     88        * */ 
     89        virtual bool Play(double absoluteTimestamp, double length) = 0; 
    9090 
    91     /* 
    92     * This will pause the feeding process 
    93     * */ 
    94     virtual bool Pause() = 0; 
     91        /* 
     92        * This will pause the feeding process 
     93        * */ 
     94        virtual bool Pause() = 0; 
    9595 
    96     /* 
    97     * This will resume the feeding process 
    98     * */ 
    99     virtual bool Resume() = 0; 
     96        /* 
     97        * This will resume the feeding process 
     98        * */ 
     99        virtual bool Resume() = 0; 
    100100 
    101     /* 
    102     * This will seek to the specified point in time. 
    103     * */ 
    104     virtual bool Seek(double absoluteTimestamp) = 0; 
     101        /* 
     102        * This will seek to the specified point in time. 
     103        * */ 
     104        virtual bool Seek(double absoluteTimestamp) = 0; 
    105105 
    106     /* 
    107     * This will stop the feeding process 
    108     * */ 
    109     virtual bool Stop() = 0; 
     106        /* 
     107        * This will stop the feeding process 
     108        * */ 
     109        virtual bool Stop() = 0; 
    110110 
    111111 
    112     /* 
    113     * Called when a play command was issued 
    114     * absoluteTimestamp - the timestamp where we want to seek 
    115     *                     before start the feeding process 
    116     * */ 
    117     virtual bool SignalPlay(double &absoluteTimestamp, double &length) = 0; 
     112        /* 
     113        * Called when a play command was issued 
     114        * absoluteTimestamp - the timestamp where we want to seek 
     115        *                     before start the feeding process 
     116        * */ 
     117        virtual bool SignalPlay(double &absoluteTimestamp, double &length) = 0; 
    118118 
    119     /* 
    120     * Called when a pasue command was issued 
    121     * */ 
    122     virtual bool SignalPause() = 0; 
     119        /* 
     120        * Called when a pasue command was issued 
     121        * */ 
     122        virtual bool SignalPause() = 0; 
    123123 
    124     /* 
    125     * Called when a resume command was issued 
    126     * */ 
    127     virtual bool SignalResume() = 0; 
     124        /* 
     125        * Called when a resume command was issued 
     126        * */ 
     127        virtual bool SignalResume() = 0; 
    128128 
    129     /* 
    130     * Called when a seek command was issued 
    131     * absoluteTimestamp - the 
    132     * */ 
    133     virtual bool SignalSeek(double &absoluteTimestamp) = 0; 
     129        /* 
     130        * Called when a seek command was issued 
     131        * absoluteTimestamp - the 
     132        * */ 
     133        virtual bool SignalSeek(double &absoluteTimestamp) = 0; 
    134134 
    135     /* 
    136     * Called when a stop command was issued 
    137     * */ 
    138     virtual bool SignalStop() = 0; 
     135        /* 
     136        * Called when a stop command was issued 
     137        * */ 
     138        virtual bool SignalStop() = 0; 
    139139 
    140     /* 
    141     * pData - the buffer containing the data 
    142     * dataLength - the size of pData in bytes 
    143     * processedLength - if pData is only partial data, this shows the numbers 
    144     *                   of bytes processed so far, excluding pData 
    145     * totalLength - if pData is only partial data, this shows the total number 
    146     *               of bytes inside the current packet 
    147     * isAudio - true if pData is audio data, false if pData is video data 
    148     * 
    149     * Rulles: 
    150     * dataLength+processedLength<=totalLength 
    151     * dataLength<=totalLength 
    152     * processedLength<=totalLength 
    153     * dataLength!=0 
    154     * */ 
    155     virtual bool FeedData(uint8_t *pData, uint32_t dataLength, 
    156             uint32_t processedLength, uint32_t totalLength, 
    157             double absoluteTimestamp, bool isAudio) = 0; 
     140        /* 
     141        * pData - the buffer containing the data 
     142        * dataLength - the size of pData in bytes 
     143        * processedLength - if pData is only partial data, this shows the numbers 
     144        *                   of bytes processed so far, excluding pData 
     145        * totalLength - if pData is only partial data, this shows the total number 
     146        *               of bytes inside the current packet 
     147        * isAudio - true if pData is audio data, false if pData is video data 
     148        * 
     149        * Rulles: 
     150        * dataLength+processedLength<=totalLength 
     151        * dataLength<=totalLength 
     152        * processedLength<=totalLength 
     153        * dataLength!=0 
     154        * */ 
     155        virtual bool FeedData(uint8_t *pData, uint32_t dataLength, 
     156                        uint32_t processedLength, uint32_t totalLength, 
     157                        double absoluteTimestamp, bool isAudio) = 0; 
    158158 
    159     /* 
    160     * The networking layer signaled the availability for sending data 
    161     * */ 
    162     virtual void ReadyForSend() = 0; 
     159        /* 
     160        * The networking layer signaled the availability for sending data 
     161        * */ 
     162        virtual void ReadyForSend() = 0; 
    163163 
    164     /* 
    165     * This is called to ensure that the linking process can be done 
    166     * type - the target type to which this strem must be linked against 
    167     * */ 
    168     virtual bool IsCompatibleWithType(uint64_t type) = 0; 
     164        /* 
     165        * This is called to ensure that the linking process can be done 
     166        * type - the target type to which this strem must be linked against 
     167        * */ 
     168        virtual bool IsCompatibleWithType(uint64_t type) = 0; 
    169169}; 
    170170 
  • trunk/sources/thelib/include/streaming/codectypes.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
  • trunk/sources/thelib/include/streaming/nalutypes.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
  • trunk/sources/thelib/include/streaming/streamsmanager.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2929class DLLEXP StreamsManager { 
    3030private: 
    31     BaseClientApplication *_pApplication; 
    32     uint32_t _uniqueIdGenerator; 
    33     map<uint32_t, BaseStream *> _streamsByUniqueId; 
    34     map<uint32_t, map<uint32_t, BaseStream *> > _streamsByProtocolId; 
    35     map<uint64_t, map<uint32_t, BaseStream * > > _streamsByType; 
    36     map<string, map<uint32_t, BaseStream * > > _streamsByName; 
     31        BaseClientApplication *_pApplication; 
     32        uint32_t _uniqueIdGenerator; 
     33        map<uint32_t, BaseStream *> _streamsByUniqueId; 
     34        map<uint32_t, map<uint32_t, BaseStream *> > _streamsByProtocolId; 
     35        map<uint64_t, map<uint32_t, BaseStream * > > _streamsByType; 
     36        map<string, map<uint32_t, BaseStream * > > _streamsByName; 
    3737public: 
    38     StreamsManager(BaseClientApplication *pApplication); 
    39     virtual ~StreamsManager(); 
     38        StreamsManager(BaseClientApplication *pApplication); 
     39        virtual ~StreamsManager(); 
    4040 
    41     /* 
    42     * returns an unique id to be used inside newly created streams 
    43     * */ 
    44     uint32_t GenerateUniqueId(); 
     41        /* 
     42        * returns an unique id to be used inside newly created streams 
     43        * */ 
     44        uint32_t GenerateUniqueId(); 
    4545 
    46     /* 
    47     * (Un)Registers a stream to the streams manager 
    48     * */ 
    49     bool RegisterStream(BaseStream *pStream); 
    50     void UnRegisterStream(BaseStream *pStream); 
    51     void UnRegisterStreams(uint32_t protocolId); 
     46        /* 
     47        * (Un)Registers a stream to the streams manager 
     48        * */ 
     49        bool RegisterStream(BaseStream *pStream); 
     50        void UnRegisterStream(BaseStream *pStream); 
     51        void UnRegisterStreams(uint32_t protocolId); 
    5252 
    53     /* 
    54     * Find streams by name 
    55     * name - the complete/partial name to search for 
    56     * partial - if true, it will match all streams that begins with name 
    57     *           otherwise it will exactly search for that name 
    58     * */ 
    59     map<uint32_t, BaseStream *> FindByName(string name, bool partial = false); 
     53        /* 
     54        * Find streams by name 
     55        * name - the complete/partial name to search for 
     56        * partial - if true, it will match all streams that begins with name 
     57        *           otherwise it will exactly search for that name 
     58        * */ 
     59        map<uint32_t, BaseStream *> FindByName(string name, bool partial = false); 
    6060 
    61     /* 
    62     * Find streams by type 
    63     * type - the complete/mask type to search for 
    64     * partial - if true, type is considered a mask 
    65     * */ 
    66     map<uint32_t, BaseStream *> FindByType(uint64_t type, bool partial = false); 
     61        /* 
     62        * Find streams by type 
     63        * type - the complete/mask type to search for 
     64        * partial - if true, type is considered a mask 
     65        * */ 
     66        map<uint32_t, BaseStream *> FindByType(uint64_t type, bool partial = false); 
    6767 
    68     /* 
    69     * Find streams by type and by name 
    70     * type - the complete/mask type to search for 
    71     * name - the complete/partial name to search for 
    72     * partialType - if true, type is considered a mask 
    73     * partialName - if true, it will match all streams that begins with name 
    74     *               otherwise it will exactly search for that name 
    75     * */ 
    76     map<uint32_t, BaseStream *> FindByTypeByName(uint64_t type, string name, 
    77             bool partialType = false, bool partialName = false); 
     68        /* 
     69        * Find streams by type and by name 
     70        * type - the complete/mask type to search for 
     71        * name - the complete/partial name to search for 
     72        * partialType - if true, type is considered a mask 
     73        * partialName - if true, it will match all streams that begins with name 
     74        *               otherwise it will exactly search for that name 
     75        * */ 
     76        map<uint32_t, BaseStream *> FindByTypeByName(uint64_t type, string name, 
     77                        bool partialType = false, bool partialName = false); 
    7878 
    79     /* 
    80     * Find all the streams belonging to a protocol 
    81     * protocolId - the protocol that owns the result streams 
    82     * */ 
    83     map<uint32_t, BaseStream *> FindByProtocolId(uint32_t protocolId); 
     79        /* 
     80        * Find all the streams belonging to a protocol 
     81        * protocolId - the protocol that owns the result streams 
     82        * */ 
     83        map<uint32_t, BaseStream *> FindByProtocolId(uint32_t protocolId); 
    8484 
    85     /* 
    86     * Find all the streams belonging to a protocol with a certain type 
    87     * protocolId - the protocol that owns the result streams 
    88     * type - the complete/mask type to search for 
    89     * partial - if true, type is considered a mask 
    90     * */ 
    91     map<uint32_t, BaseStream *> FindByProtocolIdByType(uint32_t protocolId, 
    92             uint64_t type, bool partial = false); 
     85        /* 
     86        * Find all the streams belonging to a protocol with a certain type 
     87        * protocolId - the protocol that owns the result streams 
     88        * type - the complete/mask type to search for 
     89        * partial - if true, type is considered a mask 
     90        * */ 
     91        map<uint32_t, BaseStream *> FindByProtocolIdByType(uint32_t protocolId, 
     92                        uint64_t type, bool partial = false); 
    9393 
    94     /* 
    95     * Find all the streams belonging to a protocol with a certain name 
    96     * protocolId - the protocol that owns the result streams 
    97     * name - the complete/partial name to search for 
    98     * partial - if true, it will match all streams that begins with name 
    99     *           otherwise it will exactly search for that name 
    100     * */ 
    101     map<uint32_t, BaseStream *> FindByProtocolIdByName(uint32_t protocolId, 
    102             string name, bool partial = false); 
     94        /* 
     95        * Find all the streams belonging to a protocol with a certain name 
     96        * protocolId - the protocol that owns the result streams 
     97        * name - the complete/partial name to search for 
     98        * partial - if true, it will match all streams that begins with name 
     99        *           otherwise it will exactly search for that name 
     100        * */ 
     101        map<uint32_t, BaseStream *> FindByProtocolIdByName(uint32_t protocolId, 
     102                        string name, bool partial = false); 
    103103 
    104     /* 
    105     * Find all the streams belonging to a protocol with a certain type and name 
    106     * protocolId - the protocol that owns the result streams 
    107     * type - the complete/mask type to search for 
    108     * name - the complete/partial name to search for 
    109     * partialType - if true, type is considered a mask 
    110     * partialName - if true, it will match all streams that begins with name 
    111     *               otherwise it will exactly search for that name 
    112     * */ 
    113     map<uint32_t, BaseStream *> FindByProtocolIdByTypeByName(uint32_t protocolId, 
    114             uint64_t type, string name, bool partialType = false, 
    115             bool partialName = false); 
     104        /* 
     105        * Find all the streams belonging to a protocol with a certain type and name 
     106        * protocolId - the protocol that owns the result streams 
     107        * type - the complete/mask type to search for 
     108        * name - the complete/partial name to search for 
     109        * partialType - if true, type is considered a mask 
     110        * partialName - if true, it will match all streams that begins with name 
     111        *               otherwise it will exactly search for that name 
     112        * */ 
     113        map<uint32_t, BaseStream *> FindByProtocolIdByTypeByName(uint32_t protocolId, 
     114                        uint64_t type, string name, bool partialType = false, 
     115                        bool partialName = false); 
    116116 
    117     /* 
    118     * Returns the stream with the uniqe id specified by uniqueId 
    119     * */ 
    120     BaseStream * FindByUniqueId(uint32_t uniqueId); 
     117        /* 
     118        * Returns the stream with the uniqe id specified by uniqueId 
     119        * */ 
     120        BaseStream * FindByUniqueId(uint32_t uniqueId); 
    121121}; 
    122122 
  • trunk/sources/thelib/include/streaming/streamstypes.h

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
  • trunk/sources/thelib/src/mediaformats/basemediadocument.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
    19  
    20  
    21  
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    2219 
    2320#include "mediaformats/basemediadocument.h" 
    2421 
    2522BaseMediaDocument::BaseMediaDocument(Variant &metadata) { 
    26     _audioSamplesCount = 0; 
    27     _videoSamplesCount = 0; 
    28     _metadata = metadata; 
    29     _keyframeSeek = false; 
     23        _audioSamplesCount = 0; 
     24        _videoSamplesCount = 0; 
     25        _metadata = metadata; 
     26        _keyframeSeek = false; 
    3027} 
    3128 
     
    3431 
    3532bool BaseMediaDocument::Process() { 
    36     double startTime = 0; 
    37     double endTime = 0; 
    38     GETCLOCKS(startTime); 
    39  
    40     //1. Compute the names 
    41     _mediaFilePath = (string) _metadata[META_SERVER_FULL_PATH]; 
    42     _metaFilePath = _mediaFilePath + "."MEDIA_TYPE_META; 
    43     _seekFilePath = _mediaFilePath + "."MEDIA_TYPE_SEEK; 
    44     _keyframeSeek = (bool)_metadata[CONF_APPLICATION_KEYFRAMESEEK]; 
    45     _seekGranularity = (uint32_t) _metadata[CONF_APPLICATION_SEEKGRANULARITY]; 
    46  
    47     //1. Open the media file 
     33        double startTime = 0; 
     34        double endTime = 0; 
     35        GETCLOCKS(startTime); 
     36 
     37        //1. Compute the names 
     38        _mediaFilePath = (string) _metadata[META_SERVER_FULL_PATH]; 
     39        _metaFilePath = _mediaFilePath + "."MEDIA_TYPE_META; 
     40        _seekFilePath = _mediaFilePath + "."MEDIA_TYPE_SEEK; 
     41        _keyframeSeek = (bool)_metadata[CONF_APPLICATION_KEYFRAMESEEK]; 
     42        _seekGranularity = (uint32_t) _metadata[CONF_APPLICATION_SEEKGRANULARITY]; 
     43 
     44        //1. Open the media file 
    4845#ifdef HAS_MMAP 
    49     if (!_mediaFile.Initialize(_mediaFilePath, 4 * 1024 * 1024)) { 
    50         FATAL("Unable to open media file: %s", STR(_mediaFilePath)); 
    51         return false; 
    52     } 
     46        if (!_mediaFile.Initialize(_mediaFilePath, 4 * 1024 * 1024)) { 
     47                FATAL("Unable to open media file: %s", STR(_mediaFilePath)); 
     48                return false; 
     49        } 
    5350#else 
    54     if (!_mediaFile.Initialize(_mediaFilePath)) { 
    55         FATAL("Unable to open media file: %s", STR(_mediaFilePath)); 
    56         return false; 
    57     } 
     51        if (!_mediaFile.Initialize(_mediaFilePath)) { 
     52                FATAL("Unable to open media file: %s", STR(_mediaFilePath)); 
     53                return false; 
     54        } 
    5855#endif /* HAS_MMAP */ 
    5956 
    60     //4. Read the document 
    61     if (!ParseDocument()) { 
    62         FATAL("Unable to parse document"); 
    63         return false; 
    64     } 
    65  
    66     //5. Build the frames 
    67     if (!BuildFrames()) { 
    68         FATAL("Unable to build frames"); 
    69         return false; 
    70     } 
    71  
    72     //6. Save the seek file 
    73     if (!SaveSeekFile()) { 
    74         FATAL("Unable to save seeking file"); 
    75         return false; 
    76     } 
    77  
    78     //7. Build the meta 
    79     if (!SaveMetaFile()) { 
    80         FATAL("Unable to save meta file"); 
    81         return false; 
    82     } 
    83  
    84     GETCLOCKS(endTime); 
    85  
    86     INFO("%d frames computed in %.2f seconds at a speed of %.2f FPS", 
    87             _frames.size(), 
    88             (endTime - startTime) / (double) CLOCKS_PER_SECOND, 
    89             (double) _frames.size() / ((endTime - startTime) / (double) CLOCKS_PER_SECOND)); 
    90     if (_frames.size() != 0) { 
    91         uint32_t totalSeconds = (uint32_t)(((uint32_t) _frames[_frames.size() - 1].absoluteTime) / 1000); 
    92         uint32_t hours = totalSeconds / 3600; 
    93         uint32_t minutes = (totalSeconds - hours * 3600) / 60; 
    94         uint32_t seconds = (totalSeconds - hours * 3600 - minutes * 60); 
    95         INFO("File size: %llu bytes; Duration: %d:%d:%d (%u sec); Optimal bandwidth: %.2f kb/s", 
    96                 _mediaFile.Size(), 
    97                 hours, minutes, seconds, 
    98                 totalSeconds, 
    99                 (double) _mediaFile.Size() / (double) totalSeconds / 1024.00 * 8.0); 
    100     } 
    101  
    102     return true; 
     57        //4. Read the document 
     58        if (!ParseDocument()) { 
     59                FATAL("Unable to parse document"); 
     60                return false; 
     61        } 
     62 
     63        //5. Build the frames 
     64        if (!BuildFrames()) { 
     65                FATAL("Unable to build frames"); 
     66                return false; 
     67        } 
     68 
     69        //6. Save the seek file 
     70        if (!SaveSeekFile()) { 
     71                FATAL("Unable to save seeking file"); 
     72                return false; 
     73        } 
     74 
     75        //7. Build the meta 
     76        if (!SaveMetaFile()) { 
     77                FATAL("Unable to save meta file"); 
     78                return false; 
     79        } 
     80 
     81        GETCLOCKS(endTime); 
     82 
     83        INFO("%d frames computed in %.2f seconds at a speed of %.2f FPS", 
     84                        _frames.size(), 
     85                        (endTime - startTime) / (double) CLOCKS_PER_SECOND, 
     86                        (double) _frames.size() / ((endTime - startTime) / (double) CLOCKS_PER_SECOND)); 
     87        if (_frames.size() != 0) { 
     88                uint32_t totalSeconds = (uint32_t) (((uint32_t) _frames[_frames.size() - 1].absoluteTime) / 1000); 
     89                uint32_t hours = totalSeconds / 3600; 
     90                uint32_t minutes = (totalSeconds - hours * 3600) / 60; 
     91                uint32_t seconds = (totalSeconds - hours * 3600 - minutes * 60); 
     92                INFO("File size: %llu bytes; Duration: %d:%d:%d (%u sec); Optimal bandwidth: %.2f kb/s", 
     93                                _mediaFile.Size(), 
     94                                hours, minutes, seconds, 
     95                                totalSeconds, 
     96                                (double) _mediaFile.Size() / (double) totalSeconds / 1024.00 * 8.0); 
     97        } 
     98 
     99        return true; 
    103100} 
    104101 
    105102Variant BaseMediaDocument::GetMetadata() { 
    106     return _metadata; 
     103        return _metadata; 
    107104} 
    108105 
    109106bool BaseMediaDocument::CompareFrames(const MediaFrame &frame1, const MediaFrame &frame2) { 
    110     if (frame1.absoluteTime == frame2.absoluteTime) 
    111         return frame1.start < frame2.start; 
    112     return frame1.absoluteTime < frame2.absoluteTime; 
     107        if (frame1.absoluteTime == frame2.absoluteTime) 
     108                return frame1.start < frame2.start; 
     109        return frame1.absoluteTime < frame2.absoluteTime; 
    113110} 
    114111 
    115112bool BaseMediaDocument::SaveSeekFile() { 
    116     if (_frames.size() <= 2) { 
    117         FATAL("No frames found"); 
    118         return false; 
    119     } 
    120  
    121     File seekFile; 
    122  
    123     //1. Open the file 
    124     if (!seekFile.Initialize(_seekFilePath, true, false)) { 
    125         FATAL("Unable to open seeking file %s", STR(_seekFilePath)); 
    126         return false; 
    127     } 
    128  
    129     //2. Write the number of frames 
    130     uint32_t framesCount = _frames.size(); 
    131     if (!seekFile.WriteUI32(framesCount, false)) { 
    132         FATAL("Unable to write frame count"); 
    133         return false; 
    134     } 
    135  
    136     //3. Write the frames 
    137     bool hasVideo = false; 
    138     uint64_t maxFrameSize = 0; 
    139  
    140     FOR_VECTOR(_frames, i) { 
    141         MediaFrame frame = _frames[i]; 
    142         if (maxFrameSize < frame.length) { 
    143             WARN("maxFrameSize bumped up: %llu -> %llu", maxFrameSize, frame.length); 
    144             maxFrameSize = frame.length; 
    145         } 
    146         hasVideo |= (frame.type == MEDIAFRAME_TYPE_VIDEO); 
    147         if (!seekFile.WriteBuffer((uint8_t *) & frame, sizeof (frame))) { 
    148             FATAL("Unable to write frame"); 
    149             return false; 
    150         } 
    151     } 
    152     _keyframeSeek &= hasVideo; 
    153  
    154     //4. Write the seek granularity 
    155     if (!seekFile.WriteUI32(_seekGranularity, false)) { 
    156         FATAL("Unable to write sampling rate"); 
    157         return false; 
    158     } 
    159  
    160     //4. create the time to frame index table. First, see what is the total time 
    161     double totalTime = 0; 
    162  
    163     if (framesCount >= 1) { 
    164         totalTime = _frames[framesCount - 1].absoluteTime; 
    165         //FINEST("totalTime: %f", totalTime); 
    166  
    167         //5. build the table 
    168         uint32_t frameIndex = 0; 
    169         uint32_t seekPoint = 0; 
    170         for (double i = 0; i <= totalTime; i += _seekGranularity) { 
    171             //FINEST("i: %.2f; frameIndex: %d", i, frameIndex); 
    172             while (_frames[frameIndex].absoluteTime < i) { 
    173                 //FINEST("frame: %.2f", _frames[frameIndex].absoluteTime); 
    174                 frameIndex++; 
    175                 if (frameIndex >= framesCount) 
    176                     break; 
    177  
    178                 if (_keyframeSeek) { 
    179                     if ((_frames[frameIndex].type == MEDIAFRAME_TYPE_VIDEO) 
    180                             && (_frames[frameIndex].isKeyFrame)) { 
    181                         //WARN("Seek point"); 
    182                         seekPoint = frameIndex; 
    183                     } 
    184                 } else { 
    185                     seekPoint = frameIndex; 
    186                 } 
    187             } 
    188             if (frameIndex >= framesCount) 
    189                 break; 
    190             //FINEST("%.2f -> %.2f", i, _frames[frameIndex].absoluteTime); 
    191             if (!seekFile.WriteUI32(seekPoint, false)) { 
    192                 FATAL("Unable to write frame index"); 
    193                 return false; 
    194             } 
    195         } 
    196     } 
    197  
    198     //6. Save the max frame size 
    199     if (!seekFile.WriteUI64(maxFrameSize, false)) { 
    200         FATAL("Unable to write frame count"); 
    201         return false; 
    202     } 
    203  
    204     //7. Done 
    205     return true; 
     113        if (_frames.size() <= 2) { 
     114                FATAL("No frames found"); 
     115                return false; 
     116        } 
     117 
     118        File seekFile; 
     119 
     120        //1. Open the file 
     121        if (!seekFile.Initialize(_seekFilePath, true, false)) { 
     122                FATAL("Unable to open seeking file %s", STR(_seekFilePath)); 
     123                return false; 
     124        } 
     125 
     126        //2. Write the number of frames 
     127        uint32_t framesCount = _frames.size(); 
     128        if (!seekFile.WriteUI32(framesCount, false)) { 
     129                FATAL("Unable to write frame count"); 
     130                return false; 
     131        } 
     132 
     133        //3. Write the frames 
     134        bool hasVideo = false; 
     135        uint64_t maxFrameSize = 0; 
     136 
     137        FOR_VECTOR(_frames, i) { 
     138                MediaFrame frame = _frames[i]; 
     139                if (maxFrameSize < frame.length) { 
     140                        WARN("maxFrameSize bumped up: %llu -> %llu", maxFrameSize, frame.length); 
     141                        maxFrameSize = frame.length; 
     142                } 
     143                hasVideo |= (frame.type == MEDIAFRAME_TYPE_VIDEO); 
     144                if (!seekFile.WriteBuffer((uint8_t *) & frame, sizeof (frame))) { 
     145                        FATAL("Unable to write frame"); 
     146                        return false; 
     147                } 
     148        } 
     149        _keyframeSeek &= hasVideo; 
     150 
     151        //4. Write the seek granularity 
     152        if (!seekFile.WriteUI32(_seekGranularity, false)) { 
     153                FATAL("Unable to write sampling rate"); 
     154                return false; 
     155        } 
     156 
     157        //4. create the time to frame index table. First, see what is the total time 
     158        double totalTime = 0; 
     159 
     160        if (framesCount >= 1) { 
     161                totalTime = _frames[framesCount - 1].absoluteTime; 
     162                //FINEST("totalTime: %f", totalTime); 
     163 
     164                //5. build the table 
     165                uint32_t frameIndex = 0; 
     166                uint32_t seekPoint = 0; 
     167                for (double i = 0; i <= totalTime; i += _seekGranularity) { 
     168                        //FINEST("i: %.2f; frameIndex: %d", i, frameIndex); 
     169                        while (_frames[frameIndex].absoluteTime < i) { 
     170                                //FINEST("frame: %.2f", _frames[frameIndex].absoluteTime); 
     171                                frameIndex++; 
     172                                if (frameIndex >= framesCount) 
     173                                        break; 
     174 
     175                                if (_keyframeSeek) { 
     176                                        if ((_frames[frameIndex].type == MEDIAFRAME_TYPE_VIDEO) 
     177                                                        && (_frames[frameIndex].isKeyFrame)) { 
     178                                                //WARN("Seek point"); 
     179                                                seekPoint = frameIndex; 
     180                                        } 
     181                                } else { 
     182                                        seekPoint = frameIndex; 
     183                                } 
     184                        } 
     185                        if (frameIndex >= framesCount) 
     186                                break; 
     187                        //FINEST("%.2f -> %.2f", i, _frames[frameIndex].absoluteTime); 
     188                        if (!seekFile.WriteUI32(seekPoint, false)) { 
     189                                FATAL("Unable to write frame index"); 
     190                                return false; 
     191                        } 
     192                } 
     193        } 
     194 
     195        //6. Save the max frame size 
     196        if (!seekFile.WriteUI64(maxFrameSize, false)) { 
     197                FATAL("Unable to write frame count"); 
     198                return false; 
     199        } 
     200 
     201        //7. Done 
     202        return true; 
    206203} 
    207204 
    208205bool BaseMediaDocument::SaveMetaFile() { 
    209     _metadata[META_AUDIO_FRAMES_COUNT] = _audioSamplesCount; 
    210     _metadata[META_VIDEO_FRAMES_COUNT] = _videoSamplesCount; 
    211     _metadata[META_TOTAL_FRAMES_COUNT] = (uint32_t) _frames.size(); 
    212  
    213     _metadata[META_FILE_SIZE] = (uint64_t) _mediaFile.Size(); 
    214     if (_frames.size() > 0) { 
    215         _metadata[META_FILE_DURATION] = (uint32_t) _frames[_frames.size() - 1].absoluteTime; 
    216     } else { 
    217         _metadata[META_FILE_DURATION] = (uint32_t) 0; 
    218     } 
    219  
    220     _metadata[META_RTMP_META] = GetRTMPMeta(); 
    221     _metadata[META_RTMP_META]["duration"] = (double) _metadata[META_FILE_DURATION] / 1000.00; 
    222  
    223     //FINEST("metadata:\n%s", STR(metadata.ToString())); 
    224     return _metadata.SerializeToBinFile(_metaFilePath); 
    225 } 
    226  
     206        _metadata[META_AUDIO_FRAMES_COUNT] = _audioSamplesCount; 
     207        _metadata[META_VIDEO_FRAMES_COUNT] = _videoSamplesCount; 
     208        _metadata[META_TOTAL_FRAMES_COUNT] = (uint32_t) _frames.size(); 
     209 
     210        _metadata[META_FILE_SIZE] = (uint64_t) _mediaFile.Size(); 
     211        if (_frames.size() > 0) { 
     212                _metadata[META_FILE_DURATION] = (uint32_t) _frames[_frames.size() - 1].absoluteTime; 
     213        } else { 
     214                _metadata[META_FILE_DURATION] = (uint32_t) 0; 
     215        } 
     216 
     217        _metadata[META_RTMP_META] = GetRTMPMeta(); 
     218        _metadata[META_RTMP_META]["duration"] = (double) _metadata[META_FILE_DURATION] / 1000.00; 
     219 
     220        //FINEST("metadata:\n%s", STR(metadata.ToString())); 
     221        return _metadata.SerializeToBinFile(_metaFilePath); 
     222} 
  • trunk/sources/thelib/src/mediaformats/flv/flvdocument.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_FLV 
    2121#include "utils/file.h" 
    2222#include "mediaformats/flv/flvdocument.h" 
     
    3434 
    3535bool FLVDocument::ParseDocument() { 
    36     return true; 
     36        return true; 
    3737} 
    3838 
    3939bool FLVDocument::BuildFrames() { 
    4040 
    41     //1. Go to the beginning of the file 
    42     if (!_mediaFile.SeekBegin()) { 
    43         FATAL("Unable to seek in file"); 
    44         return false; 
    45     } 
     41        //1. Go to the beginning of the file 
     42        if (!_mediaFile.SeekBegin()) { 
     43                FATAL("Unable to seek in file"); 
     44                return false; 
     45        } 
    4646 
    47     //2. Ignore the flv header 
    48     if (!_mediaFile.SeekAhead(9)) { 
    49         FATAL("Unable to seek in file"); 
    50         return false; 
    51     } 
     47        //2. Ignore the flv header 
     48        if (!_mediaFile.SeekAhead(9)) { 
     49                FATAL("Unable to seek in file"); 
     50                return false; 
     51        } 
    5252 
    53     //3. We are not interested in the previous tag size 
    54     if (!_mediaFile.SeekAhead(4)) { 
    55         FATAL("Unable to seek in file"); 
    56         return false; 
    57     } 
     53        //3. We are not interested in the previous tag size 
     54        if (!_mediaFile.SeekAhead(4)) { 
     55                FATAL("Unable to seek in file"); 
     56                return false; 
     57        } 
    5858 
    59     //4. Build the frames 
    60     MediaFrame frame = {0}; 
    61     uint8_t tagType = 0; 
    62     uint32_t timestamp; 
    63     while (_mediaFile.Cursor() != _mediaFile.Size()) { 
    64         //5. Read the tag type 
    65         if (!_mediaFile.ReadUI8(&tagType)) { 
    66             WARN("Unable to read data"); 
    67             break; 
    68         } 
     59        //4. Build the frames 
     60        MediaFrame frame = {0}; 
     61        uint8_t tagType = 0; 
     62        uint32_t timestamp; 
     63        while (_mediaFile.Cursor() != _mediaFile.Size()) { 
     64                //5. Read the tag type 
     65                if (!_mediaFile.ReadUI8(&tagType)) { 
     66                        WARN("Unable to read data"); 
     67                        break; 
     68                } 
    6969 
    70         //6. Set the frame type based on the tag type 
    71         //Also set the iskeyFrame property here 
    72         switch (tagType) { 
    73             case 8: //audio data 
    74                 _audioSamplesCount++; 
    75                 frame.type = MEDIAFRAME_TYPE_AUDIO; 
    76                 break; 
    77             case 9: //video data 
    78                 _videoSamplesCount++; 
    79                 frame.type = MEDIAFRAME_TYPE_VIDEO; 
    80                 break; 
    81             case 18: //info data 
    82                 frame.type = MEDIAFRAME_TYPE_DATA; 
    83                 break; 
    84             default: 
    85                 WARN("Invalid tag type: %d at cursor %llu", tagType, _mediaFile.Cursor()); 
    86                 return true; 
    87         } 
     70                //6. Set the frame type based on the tag type 
     71                //Also set the iskeyFrame property here 
     72                switch (tagType) { 
     73                        case 8: //audio data 
     74                                _audioSamplesCount++; 
     75                                frame.type = MEDIAFRAME_TYPE_AUDIO; 
     76                                break; 
     77                        case 9: //video data 
     78                                _videoSamplesCount++; 
     79                                frame.type = MEDIAFRAME_TYPE_VIDEO; 
     80                                break; 
     81                        case 18: //info data 
     82                                frame.type = MEDIAFRAME_TYPE_DATA; 
     83                                break; 
     84                        default: 
     85                                WARN("Invalid tag type: %d at cursor %llu", tagType, _mediaFile.Cursor()); 
     86                                return true; 
     87                } 
    8888 
    89         //7. Read the frame length 
    90         uint32_t tempLength; 
    91         if (!_mediaFile.ReadUI24(&tempLength)) { 
    92             WARN("Unable to read data"); 
    93             break; 
    94         } 
    95         frame.length = tempLength; 
     89                //7. Read the frame length 
     90                uint32_t tempLength; 
     91                if (!_mediaFile.ReadUI24(&tempLength)) { 
     92                        WARN("Unable to read data"); 
     93                        break; 
     94                } 
     95                frame.length = tempLength; 
    9696 
    97         //8. read the timestamp and set the timing on the frame 
    98         if (!_mediaFile.ReadSUI32(&timestamp)) { 
    99             WARN("Unable to read data"); 
    100             break; 
    101         } 
    102         //TODO: correctly compute delta time 
    103         frame.deltaTime = 0; 
    104         frame.absoluteTime = timestamp; 
     97                //8. read the timestamp and set the timing on the frame 
     98                if (!_mediaFile.ReadSUI32(&timestamp)) { 
     99                        WARN("Unable to read data"); 
     100                        break; 
     101                } 
     102                //TODO: correctly compute delta time 
     103                frame.deltaTime = 0; 
     104                frame.absoluteTime = timestamp; 
    105105 
    106         //9. Ignore the stream ID 
    107         if (!_mediaFile.SeekAhead(3)) { 
    108             WARN("Unable to seek in file"); 
    109             break; 
    110         } 
     106                //9. Ignore the stream ID 
     107                if (!_mediaFile.SeekAhead(3)) { 
     108                        WARN("Unable to seek in file"); 
     109                        break; 
     110                } 
    111111 
    112         //10. Save the start of the data 
    113         frame.start = _mediaFile.Cursor(); 
     112                //10. Save the start of the data 
     113                frame.start = _mediaFile.Cursor(); 
    114114 
    115         //11. Set the isKeyFrame flag 
    116         if (frame.type == MEDIAFRAME_TYPE_VIDEO) { 
    117             uint8_t byte = 0; 
    118             if (!_mediaFile.PeekUI8(&byte)) { 
    119                 FATAL("Unable to peek byte"); 
    120                 return false; 
    121             } 
    122             frame.isKeyFrame = ((byte >> 4) == 1); 
    123         } else { 
    124             frame.isKeyFrame = true; 
    125         } 
     115                //11. Set the isKeyFrame flag 
     116                if (frame.type == MEDIAFRAME_TYPE_VIDEO) { 
     117                        uint8_t byte = 0; 
     118                        if (!_mediaFile.PeekUI8(&byte)) { 
     119                                FATAL("Unable to peek byte"); 
     120                                return false; 
     121                        } 
     122                        frame.isKeyFrame = ((byte >> 4) == 1); 
     123                } else { 
     124                        frame.isKeyFrame = true; 
     125                } 
    126126 
    127         //12. Read the metadata or ignore the data payload 
    128         if (frame.type == MEDIAFRAME_TYPE_DATA) { 
    129             IOBuffer tempBuffer; 
    130             tempBuffer.ReadFromFs(_mediaFile, frame.length); 
    131             //tempBuffer.PutInputBuffer(&buffer, 0, length); 
     127                //12. Read the metadata or ignore the data payload 
     128                if (frame.type == MEDIAFRAME_TYPE_DATA) { 
     129                        IOBuffer tempBuffer; 
     130                        tempBuffer.ReadFromFs(_mediaFile, frame.length); 
     131                        //tempBuffer.PutInputBuffer(&buffer, 0, length); 
    132132#ifdef HAS_PROTOCOL_RTMP 
    133             AMF0Serializer amfSerializer; 
     133                        AMF0Serializer amfSerializer; 
    134134 
    135             string name = ""; 
    136             Variant parameters; 
     135                        string name = ""; 
     136                        Variant parameters; 
    137137 
    138             Variant tempVariant; 
    139             if (!amfSerializer.Read(tempBuffer, tempVariant)) { 
    140                 FATAL("Unable to read metadata"); 
    141                 return false; 
    142             } 
    143             if (tempVariant != V_STRING) { 
    144                 FATAL("Unable to read metadata"); 
    145                 return false; 
    146             } 
    147             name = ((string) tempVariant); 
     138                        Variant tempVariant; 
     139                        if (!amfSerializer.Read(tempBuffer, tempVariant)) { 
     140                                FATAL("Unable to read metadata"); 
     141                                return false; 
     142                        } 
     143                        if (tempVariant != V_STRING) { 
     144                                FATAL("Unable to read metadata"); 
     145                                return false; 
     146                        } 
     147                        name = ((string) tempVariant); 
    148148 
    149             while (GETAVAILABLEBYTESCOUNT(tempBuffer) > 0) { 
    150                 tempVariant.Reset(); 
    151                 if (!amfSerializer.Read(tempBuffer, tempVariant)) { 
    152                     FATAL("Unable to read metadata"); 
    153                     return false; 
    154                 } 
    155                 parameters.PushToArray(tempVariant); 
    156             } 
     149                        while (GETAVAILABLEBYTESCOUNT(tempBuffer) > 0) { 
     150                                tempVariant.Reset(); 
     151                                if (!amfSerializer.Read(tempBuffer, tempVariant)) { 
     152                                        FATAL("Unable to read metadata"); 
     153                                        return false; 
     154                                } 
     155                                parameters.PushToArray(tempVariant); 
     156                        } 
    157157 
    158             //            FINEST("name:\n%s", STR(name)); 
    159             //            FINEST("parameters:\n%s", STR(parameters.ToString())); 
    160             if (_metadata == V_NULL) 
    161                 _metadata = parameters[(uint32_t) 0]; 
     158                        //            FINEST("name:\n%s", STR(name)); 
     159                        //            FINEST("parameters:\n%s", STR(parameters.ToString())); 
     160                        if (_metadata == V_NULL) 
     161                                _metadata = parameters[(uint32_t) 0]; 
    162162#endif 
    163         } else { 
    164             if (!_mediaFile.SeekAhead(frame.length)) { 
    165                 WARN("Unable to seek in file"); 
    166                 break; 
    167             } 
    168         } 
     163                } else { 
     164                        if (!_mediaFile.SeekAhead(frame.length)) { 
     165                                WARN("Unable to seek in file"); 
     166                                break; 
     167                        } 
     168                } 
    169169 
    170         //13. We are not interested in the previous tag size 
    171         if (!_mediaFile.SeekAhead(4)) { 
    172             WARN("Unable to seek in file"); 
    173             break; 
    174         } 
     170                //13. We are not interested in the previous tag size 
     171                if (!_mediaFile.SeekAhead(4)) { 
     172                        WARN("Unable to seek in file"); 
     173                        break; 
     174                } 
    175175 
    176         //14. This is not a binary frame 
    177         frame.isBinaryHeader = false; 
     176                //14. This is not a binary frame 
     177                frame.isBinaryHeader = false; 
    178178 
    179         //15. Save the frame to the frame list 
    180         ADD_VECTOR_END(_frames, frame); 
    181     } 
     179                //15. Save the frame to the frame list 
     180                ADD_VECTOR_END(_frames, frame); 
     181        } 
    182182 
    183     //    for (uint32_t i = 0; i < 50; i++) { 
    184     //        FINEST("Before:%s", STR(_frames[i])); 
    185     //    } 
    186     sort(_frames.begin(), _frames.end(), CompareFrames); 
    187     //    for (uint32_t i = 0; i < _frames.size(); i++) { 
    188     //        FINEST("After:%s", STR(_frames[i])); 
    189     //    } 
    190     //    NYIR; 
     183        //    for (uint32_t i = 0; i < 50; i++) { 
     184        //        FINEST("Before:%s", STR(_frames[i])); 
     185        //    } 
     186        sort(_frames.begin(), _frames.end(), CompareFrames); 
     187        //    for (uint32_t i = 0; i < _frames.size(); i++) { 
     188        //        FINEST("After:%s", STR(_frames[i])); 
     189        //    } 
     190        //    NYIR; 
    191191 
    192     return true; 
     192        return true; 
    193193} 
    194194 
    195195Variant FLVDocument::GetRTMPMeta() { 
    196     return _metadata; 
     196        return _metadata; 
    197197} 
    198198 
     199#endif /* HAS_MEDIA_FLV */ 
  • trunk/sources/thelib/src/mediaformats/mp3/id3parser.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
    19  
    20  
    21  
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
     19 
     20 
     21#ifdef HAS_MEDIA_MP3 
    2222#include "mediaformats/mp3/id3parser.h" 
    2323#include "protocols/baseprotocol.h" 
     
    3535 
    3636ID3Parser::ID3Parser(uint32_t majorVersion, uint32_t minorVersion) { 
    37     _majorVersion = majorVersion; 
    38     _minorVersion = minorVersion; 
    39     _unsynchronisation = false; 
    40     _compression = false; 
    41     _extendedHeader = false; 
    42     _experimentalIndicator = false; 
    43     _footerPresent = false; 
     37        _majorVersion = majorVersion; 
     38        _minorVersion = minorVersion; 
     39        _unsynchronisation = false; 
     40        _compression = false; 
     41        _extendedHeader = false; 
     42        _experimentalIndicator = false; 
     43        _footerPresent = false; 
    4444} 
    4545 
     
    4848 
    4949Variant ID3Parser::GetMetadata() { 
    50     return _metadata; 
     50        return _metadata; 
    5151} 
    5252 
     
    5858#endif /* HAS_MMAP */ 
    5959{ 
    60     _metadata.Reset(); 
    61  
    62     //http://www.id3.org/d3v2.3.0 
    63     //1. Read the flags 
    64     uint8_t flags; 
    65     if (!file.ReadBuffer(&flags, 1)) { 
    66         WARN("Unable to read 1 byte"); 
    67         return false; 
    68     } 
    69     switch (_majorVersion) { 
    70         case 3: 
    71         { 
    72             _unsynchronisation = ((flags >> 7) != 0); 
    73             _extendedHeader = (((flags >> 6)&0x01) != 0); 
    74             _experimentalIndicator = (((flags >> 5)&0x01) != 0); 
    75             break; 
    76         } 
    77         case 4: 
    78         { 
    79             _unsynchronisation = ((flags >> 7) != 0); 
    80             _extendedHeader = (((flags >> 6)&0x01) != 0); 
    81             _experimentalIndicator = (((flags >> 5)&0x01) != 0); 
    82             _footerPresent = (((flags >> 4)&0x01) != 0); 
    83             break; 
    84         } 
    85         default: 
    86         { 
    87             WARN("Invalid version: ID3v%d.%d", _majorVersion, _minorVersion); 
    88             return false; 
    89         } 
    90     } 
    91  
    92  
    93     //2. Read the size 
    94     uint8_t tempBuffer[4]; 
    95     if (!file.ReadBuffer(tempBuffer, 4)) { 
    96         WARN("Unable to read 4 bytes"); 
    97         return false; 
    98     } 
    99     uint32_t totalSize = (tempBuffer[0]&0x7f); 
    100     totalSize = (totalSize << 7) | (tempBuffer[1]&0x7f); 
    101     totalSize = (totalSize << 7) | (tempBuffer[2]&0x7f); 
    102     totalSize = (totalSize << 7) | (tempBuffer[3]&0x7f); 
    103     //FINEST("_totalSize: 0x%08x (%d)", _totalSize, _totalSize); 
    104  
    105     //3. See if we go to the end of the ID3 we have a valid media frame 
    106     //After that we go back to where we left (end of the header, offset 10) 
    107     if (!file.SeekTo(totalSize + 10)) { 
    108         WARN("Unable to seek to 0x%08x offset", totalSize); 
    109         return false; 
    110     } 
    111  
    112     if (!file.ReadBuffer(tempBuffer, 2)) { 
    113         WARN("Unable to read 2 bytes"); 
    114         return false; 
    115     } 
    116     if ((tempBuffer[0] != 0xff) || ((tempBuffer[1] >> 5) != 7)) { 
    117         WARN("Unable to position on frame data."); 
    118         return false; 
    119     } 
    120     if (!file.SeekTo(10)) { 
    121         WARN("Unable to seek to 0x0a offset"); 
    122         return false; 
    123     } 
    124  
    125     //4. Skip the extended header 
    126     if (_extendedHeader) { 
    127         NYIR; 
    128     } 
    129  
    130     //5. Store the tags inside a IOBuffer 
    131     IOBuffer buffer; 
    132     if (!buffer.ReadFromFs(file, totalSize)) { 
    133         WARN("Unable to read %d bytes", totalSize); 
    134         return false; 
    135     } 
    136  
    137     if (!ParseTags(buffer)) { 
    138         WARN("Unable to parse the tags. Metadata might be incomplete"); 
    139     } 
    140  
    141     return true; 
     60        _metadata.Reset(); 
     61 
     62        //http://www.id3.org/d3v2.3.0 
     63        //1. Read the flags 
     64        uint8_t flags; 
     65        if (!file.ReadBuffer(&flags, 1)) { 
     66                WARN("Unable to read 1 byte"); 
     67                return false; 
     68        } 
     69        switch (_majorVersion) { 
     70                case 3: 
     71                { 
     72                        _unsynchronisation = ((flags >> 7) != 0); 
     73                        _extendedHeader = (((flags >> 6)&0x01) != 0); 
     74                        _experimentalIndicator = (((flags >> 5)&0x01) != 0); 
     75                        break; 
     76                } 
     77                case 4: 
     78                { 
     79                        _unsynchronisation = ((flags >> 7) != 0); 
     80                        _extendedHeader = (((flags >> 6)&0x01) != 0); 
     81                        _experimentalIndicator = (((flags >> 5)&0x01) != 0); 
     82                        _footerPresent = (((flags >> 4)&0x01) != 0); 
     83                        break; 
     84                } 
     85                default: 
     86                { 
     87                        WARN("Invalid version: ID3v%d.%d", _majorVersion, _minorVersion); 
     88                        return false; 
     89                } 
     90        } 
     91 
     92 
     93        //2. Read the size 
     94        uint8_t tempBuffer[4]; 
     95        if (!file.ReadBuffer(tempBuffer, 4)) { 
     96                WARN("Unable to read 4 bytes"); 
     97                return false; 
     98        } 
     99        uint32_t totalSize = (tempBuffer[0]&0x7f); 
     100        totalSize = (totalSize << 7) | (tempBuffer[1]&0x7f); 
     101        totalSize = (totalSize << 7) | (tempBuffer[2]&0x7f); 
     102        totalSize = (totalSize << 7) | (tempBuffer[3]&0x7f); 
     103        //FINEST("_totalSize: 0x%08x (%d)", _totalSize, _totalSize); 
     104 
     105        //3. See if we go to the end of the ID3 we have a valid media frame 
     106        //After that we go back to where we left (end of the header, offset 10) 
     107        if (!file.SeekTo(totalSize + 10)) { 
     108                WARN("Unable to seek to 0x%08x offset", totalSize); 
     109                return false; 
     110        } 
     111 
     112        if (!file.ReadBuffer(tempBuffer, 2)) { 
     113                WARN("Unable to read 2 bytes"); 
     114                return false; 
     115        } 
     116        if ((tempBuffer[0] != 0xff) || ((tempBuffer[1] >> 5) != 7)) { 
     117                WARN("Unable to position on frame data."); 
     118                return false; 
     119        } 
     120        if (!file.SeekTo(10)) { 
     121                WARN("Unable to seek to 0x0a offset"); 
     122                return false; 
     123        } 
     124 
     125        //4. Skip the extended header 
     126        if (_extendedHeader) { 
     127                NYIR; 
     128        } 
     129 
     130        //5. Store the tags inside a IOBuffer 
     131        IOBuffer buffer; 
     132        if (!buffer.ReadFromFs(file, totalSize)) { 
     133                WARN("Unable to read %d bytes", totalSize); 
     134                return false; 
     135        } 
     136 
     137        if (!ParseTags(buffer)) { 
     138                WARN("Unable to parse the tags. Metadata might be incomplete"); 
     139        } 
     140 
     141        return true; 
    142142} 
    143143 
     
    150150 
    151151bool ID3Parser::ParseTags(IOBuffer &buffer) { 
    152     IOBuffer tagBuffer; 
    153     Variant tag; 
    154     while (GETAVAILABLEBYTESCOUNT(buffer) != 0) { 
    155  
    156         //1. Read the tag type 
    157         CHECK_BUFFER_SIZE(buffer, 4); 
    158         string name = string((char *) GETIBPOINTER(buffer), 4); 
    159         if ( 
    160                 (!(((name[0] >= 'A') && (name[0] <= 'Z')) || ((name[0] >= '0') && (name[0] <= '9')))) || 
    161                 (!(((name[1] >= 'A') && (name[1] <= 'Z')) || ((name[1] >= '0') && (name[1] <= '9')))) || 
    162                 (!(((name[2] >= 'A') && (name[2] <= 'Z')) || ((name[2] >= '0') && (name[2] <= '9')))) || 
    163                 (!(((name[3] >= 'A') && (name[3] <= 'Z')) || ((name[3] >= '0') && (name[3] <= '9')))) 
    164                 ) { 
    165             if ((name[0] == 0) && (name[1] == 0) && (name[2] == 0) && (name[3] == 0)) { 
    166                 return true; 
    167             } else { 
    168                 WARN("Invalid tag name: %d %d %d %d", 
    169                         name[0], name[1], name[2], name[3]); 
    170                 return false; 
    171             } 
    172         } 
    173         uint64_t id = MAKE_TAG4(name[0], name[1], name[2], name[3]); 
    174         buffer.Ignore(4); 
    175  
    176  
    177  
    178         //2. Read the size and the flags 
    179         CHECK_BUFFER_SIZE(buffer, 4); 
    180         uint32_t size = 0; 
    181         if (_majorVersion == 4) { 
    182             size = (GETIBPOINTER(buffer)[0]&0x7f); 
    183             size = (size << 7) | (GETIBPOINTER(buffer)[1]&0x7f); 
    184             size = (size << 7) | (GETIBPOINTER(buffer)[2]&0x7f); 
    185             size = (size << 7) | (GETIBPOINTER(buffer)[3]&0x7f); 
    186         } else { 
    187             size = ntohlp(GETIBPOINTER(buffer)); 
    188         } 
    189         //FINEST("name: %s; size: %d", STR(name), size); 
    190         buffer.Ignore(4); 
    191  
    192         CHECK_BUFFER_SIZE(buffer, 2); 
    193         //uint16_t flags = ntohsp(GETIBPOINTER(buffer)); 
    194         buffer.Ignore(2); 
    195         if (size == 0 || GETAVAILABLEBYTESCOUNT(buffer) < size) { 
    196             WARN("Invalid tagSize"); 
    197             return false; 
    198         } 
    199         //FINEST("id: %08x; name: %s; size: %d; flags: %d", id, STR(name), size, flags); 
    200  
    201         //3. Get a copy of data 
    202         tagBuffer.IgnoreAll(); 
    203         tagBuffer.ReadFromBuffer(GETIBPOINTER(buffer), size); 
    204         buffer.Ignore(size); 
    205  
    206         //4. Parse 
    207         tag.Reset(); 
    208         if (id == TAG_USLT) { 
    209             if (!ParseUSLT(tagBuffer, tag)) { 
    210                 WARN("Unable to parse tag %s", STR(name)); 
    211             } 
    212             _metadata[name] = tag; 
    213         } else if (id == TAG_APIC) { 
    214             if (!ParseAPIC(tagBuffer, tag)) { 
    215                 WARN("Unable to parse tag %s", STR(name)); 
    216             } 
    217             _metadata[name] = tag; 
    218         } else if (id == TAG_COMM) { 
    219             if (!ParseCOMM(tagBuffer, tag)) { 
    220                 WARN("Unable to parse tag %s", STR(name)); 
    221             } 
    222             _metadata[name] = tag; 
    223         } else if (id == TAG_TXXX) { 
    224             if (!ParseTXXX(tagBuffer, tag)) { 
    225                 WARN("Unable to parse tag %s", STR(name)); 
    226             } 
    227             _metadata[name] = tag; 
    228         } else if (id == TAG_WXXX) { 
    229             if (!ParseWXXX(tagBuffer, tag)) { 
    230                 WARN("Unable to parse tag %s", STR(name)); 
    231             } 
    232             _metadata[name] = tag; 
    233         } else if (id >= TAG_START_TEXT && id <= TAG_END_TEXT) { 
    234             if (!ParseTextTag(tagBuffer, tag)) { 
    235                 WARN("Unable to parse tag %s", STR(name)); 
    236             } 
    237             _metadata[name] = tag; 
    238         } else if (id >= TAG_START_URL && id <= TAG_END_URL) { 
    239             if (!ParseUrlTag(tagBuffer, tag)) { 
    240                 WARN("Unable to parse tag %s", STR(name)); 
    241             } 
    242             _metadata[name] = tag; 
    243         } else { 
    244             WARN("tag %s not yet implemented", STR(name)); 
    245             _metadata[name] = string((char *) GETIBPOINTER(tagBuffer), 
    246                     GETAVAILABLEBYTESCOUNT(tagBuffer)); 
    247             _metadata[name].IsByteArray(true); 
    248         } 
    249     } 
    250     return true; 
     152        IOBuffer tagBuffer; 
     153        Variant tag; 
     154        while (GETAVAILABLEBYTESCOUNT(buffer) != 0) { 
     155 
     156                //1. Read the tag type 
     157                CHECK_BUFFER_SIZE(buffer, 4); 
     158                string name = string((char *) GETIBPOINTER(buffer), 4); 
     159                if ( 
     160                                (!(((name[0] >= 'A') && (name[0] <= 'Z')) || ((name[0] >= '0') && (name[0] <= '9')))) || 
     161                                (!(((name[1] >= 'A') && (name[1] <= 'Z')) || ((name[1] >= '0') && (name[1] <= '9')))) || 
     162                                (!(((name[2] >= 'A') && (name[2] <= 'Z')) || ((name[2] >= '0') && (name[2] <= '9')))) || 
     163                                (!(((name[3] >= 'A') && (name[3] <= 'Z')) || ((name[3] >= '0') && (name[3] <= '9')))) 
     164                                ) { 
     165                        if ((name[0] == 0) && (name[1] == 0) && (name[2] == 0) && (name[3] == 0)) { 
     166                                return true; 
     167                        } else { 
     168                                WARN("Invalid tag name: %d %d %d %d", 
     169                                                name[0], name[1], name[2], name[3]); 
     170                                return false; 
     171                        } 
     172                } 
     173                uint64_t id = MAKE_TAG4(name[0], name[1], name[2], name[3]); 
     174                buffer.Ignore(4); 
     175 
     176 
     177 
     178                //2. Read the size and the flags 
     179                CHECK_BUFFER_SIZE(buffer, 4); 
     180                uint32_t size = 0; 
     181                if (_majorVersion == 4) { 
     182                        size = (GETIBPOINTER(buffer)[0]&0x7f); 
     183                        size = (size << 7) | (GETIBPOINTER(buffer)[1]&0x7f); 
     184                        size = (size << 7) | (GETIBPOINTER(buffer)[2]&0x7f); 
     185                        size = (size << 7) | (GETIBPOINTER(buffer)[3]&0x7f); 
     186                } else { 
     187                        size = ntohlp(GETIBPOINTER(buffer)); 
     188                } 
     189                //FINEST("name: %s; size: %d", STR(name), size); 
     190                buffer.Ignore(4); 
     191 
     192                CHECK_BUFFER_SIZE(buffer, 2); 
     193                //uint16_t flags = ntohsp(GETIBPOINTER(buffer)); 
     194                buffer.Ignore(2); 
     195                if (size == 0 || GETAVAILABLEBYTESCOUNT(buffer) < size) { 
     196                        WARN("Invalid tagSize"); 
     197                        return false; 
     198                } 
     199                //FINEST("id: %08x; name: %s; size: %d; flags: %d", id, STR(name), size, flags); 
     200 
     201                //3. Get a copy of data 
     202                tagBuffer.IgnoreAll(); 
     203                tagBuffer.ReadFromBuffer(GETIBPOINTER(buffer), size); 
     204                buffer.Ignore(size); 
     205 
     206                //4. Parse 
     207                tag.Reset(); 
     208                if (id == TAG_USLT) { 
     209                        if (!ParseUSLT(tagBuffer, tag)) { 
     210                                WARN("Unable to parse tag %s", STR(name)); 
     211                        } 
     212                        _metadata[name] = tag; 
     213                } else if (id == TAG_APIC) { 
     214                        if (!ParseAPIC(tagBuffer, tag)) { 
     215                                WARN("Unable to parse tag %s", STR(name)); 
     216                        } 
     217                        _metadata[name] = tag; 
     218                } else if (id == TAG_COMM) { 
     219                        if (!ParseCOMM(tagBuffer, tag)) { 
     220                                WARN("Unable to parse tag %s", STR(name)); 
     221                        } 
     222                        _metadata[name] = tag; 
     223                } else if (id == TAG_TXXX) { 
     224                        if (!ParseTXXX(tagBuffer, tag)) { 
     225                                WARN("Unable to parse tag %s", STR(name)); 
     226                        } 
     227                        _metadata[name] = tag; 
     228                } else if (id == TAG_WXXX) { 
     229                        if (!ParseWXXX(tagBuffer, tag)) { 
     230                                WARN("Unable to parse tag %s", STR(name)); 
     231                        } 
     232                        _metadata[name] = tag; 
     233                } else if (id >= TAG_START_TEXT && id <= TAG_END_TEXT) { 
     234                        if (!ParseTextTag(tagBuffer, tag)) { 
     235                                WARN("Unable to parse tag %s", STR(name)); 
     236                        } 
     237                        _metadata[name] = tag; 
     238                } else if (id >= TAG_START_URL && id <= TAG_END_URL) { 
     239                        if (!ParseUrlTag(tagBuffer, tag)) { 
     240                                WARN("Unable to parse tag %s", STR(name)); 
     241                        } 
     242                        _metadata[name] = tag; 
     243                } else { 
     244                        WARN("tag %s not yet implemented", STR(name)); 
     245                        _metadata[name] = string((char *) GETIBPOINTER(tagBuffer), 
     246                                        GETAVAILABLEBYTESCOUNT(tagBuffer)); 
     247                        _metadata[name].IsByteArray(true); 
     248                } 
     249        } 
     250        return true; 
    251251} 
    252252 
    253253bool ID3Parser::ReadStringWithSize(IOBuffer &buffer, Variant &value, 
    254         uint32_t size, bool hasEncoding) { 
    255     CHECK_BUFFER_SIZE(buffer, size); 
    256     value = string( 
    257             (char *) (GETIBPOINTER(buffer)+(hasEncoding ? 1 : 0)), 
    258             size - (hasEncoding ? 1 : 0)); 
    259     buffer.Ignore(size); 
    260     return true; 
     254                uint32_t size, bool hasEncoding) { 
     255        CHECK_BUFFER_SIZE(buffer, size); 
     256        value = string( 
     257                        (char *) (GETIBPOINTER(buffer)+(hasEncoding ? 1 : 0)), 
     258                        size - (hasEncoding ? 1 : 0)); 
     259        buffer.Ignore(size); 
     260        return true; 
    261261} 
    262262 
    263263bool ID3Parser::ReadStringNullTerminated(IOBuffer &buffer, Variant &value, bool unicode) { 
    264     string temp = ""; 
    265     while (GETAVAILABLEBYTESCOUNT(buffer) >= (uint32_t) (unicode ? 2 : 1)) { 
    266         if (unicode) { 
    267             if ((GETIBPOINTER(buffer)[0] == 0) && (GETIBPOINTER(buffer)[1] == 0)) { 
    268                 value = temp; 
    269                 buffer.Ignore(2); 
    270                 return true; 
    271             } 
    272         } else { 
    273             if (GETIBPOINTER(buffer)[0] == 0) { 
    274                 value = temp; 
    275                 buffer.Ignore(1); 
    276                 return true; 
    277             } 
    278         } 
    279         temp += (char) GETIBPOINTER(buffer)[0]; 
    280         buffer.Ignore(1); 
    281     } 
    282     value = ""; 
    283     return false; 
     264        string temp = ""; 
     265        while (GETAVAILABLEBYTESCOUNT(buffer) >= (uint32_t) (unicode ? 2 : 1)) { 
     266                if (unicode) { 
     267                        if ((GETIBPOINTER(buffer)[0] == 0) && (GETIBPOINTER(buffer)[1] == 0)) { 
     268                                value = temp; 
     269                                buffer.Ignore(2); 
     270                                return true; 
     271                        } 
     272                } else { 
     273                        if (GETIBPOINTER(buffer)[0] == 0) { 
     274                                value = temp; 
     275                                buffer.Ignore(1); 
     276                                return true; 
     277                        } 
     278                } 
     279                temp += (char) GETIBPOINTER(buffer)[0]; 
     280                buffer.Ignore(1); 
     281        } 
     282        value = ""; 
     283        return false; 
    284284} 
    285285 
    286286bool ID3Parser::ParseTextTag(IOBuffer &buffer, Variant &tag) { 
    287     return ReadStringWithSize(buffer, tag, GETAVAILABLEBYTESCOUNT(buffer), true); 
     287        return ReadStringWithSize(buffer, tag, GETAVAILABLEBYTESCOUNT(buffer), true); 
    288288} 
    289289 
    290290bool ID3Parser::ParseUSLT(IOBuffer &buffer, Variant &tag) { 
    291     CHECK_BUFFER_SIZE(buffer, 1); 
    292     bool unicode = GETIBPOINTER(buffer)[0]; 
    293     tag["unicode"] = (bool)unicode != 0; 
    294     buffer.Ignore(1); 
    295  
    296     CHECK_BUFFER_SIZE(buffer, 3); 
    297     if (!ReadStringWithSize(buffer, tag["language"], 3, false)) { 
    298         WARN("Unable to read string"); 
    299         return false; 
    300     } 
    301  
    302     if (!ReadStringNullTerminated(buffer, tag["contentDescriptor"], unicode)) { 
    303         WARN("Unable to read string"); 
    304         return false; 
    305     } 
    306  
    307     if (!ReadStringWithSize(buffer, tag["lyrics"], GETAVAILABLEBYTESCOUNT(buffer), false)) { 
    308         WARN("Unable to read string"); 
    309         return false; 
    310     } 
    311  
    312     return true; 
     291        CHECK_BUFFER_SIZE(buffer, 1); 
     292        bool unicode = GETIBPOINTER(buffer)[0]; 
     293        tag["unicode"] = (bool)unicode != 0; 
     294        buffer.Ignore(1); 
     295 
     296        CHECK_BUFFER_SIZE(buffer, 3); 
     297        if (!ReadStringWithSize(buffer, tag["language"], 3, false)) { 
     298                WARN("Unable to read string"); 
     299                return false; 
     300        } 
     301 
     302        if (!ReadStringNullTerminated(buffer, tag["contentDescriptor"], unicode)) { 
     303                WARN("Unable to read string"); 
     304                return false; 
     305        } 
     306 
     307        if (!ReadStringWithSize(buffer, tag["lyrics"], GETAVAILABLEBYTESCOUNT(buffer), false)) { 
     308                WARN("Unable to read string"); 
     309                return false; 
     310        } 
     311 
     312        return true; 
    313313} 
    314314 
    315315bool ID3Parser::ParseAPIC(IOBuffer &buffer, Variant &tag) { 
    316     CHECK_BUFFER_SIZE(buffer, 1); 
    317     bool unicode = GETIBPOINTER(buffer)[0]; 
    318     tag["unicode"] = (bool)unicode != 0; 
    319     buffer.Ignore(1); 
    320  
    321     if (!ReadStringNullTerminated(buffer, tag["mimeType"], false)) { 
    322         WARN("Unable to read string"); 
    323         return false; 
    324     } 
    325  
    326     CHECK_BUFFER_SIZE(buffer, 1); 
    327     tag["pictureType"] = GETIBPOINTER(buffer)[0]; 
    328     buffer.Ignore(1); 
    329  
    330     if (!ReadStringNullTerminated(buffer, tag["description"], unicode)) { 
    331         WARN("Unable to read string"); 
    332         return false; 
    333     } 
    334  
    335     tag["pictureData"] = string((char *) GETIBPOINTER(buffer), 
    336             GETAVAILABLEBYTESCOUNT(buffer)); 
    337     tag["pictureData"].IsByteArray(true); 
    338  
    339     return true; 
     316        CHECK_BUFFER_SIZE(buffer, 1); 
     317        bool unicode = GETIBPOINTER(buffer)[0]; 
     318        tag["unicode"] = (bool)unicode != 0; 
     319        buffer.Ignore(1); 
     320 
     321        if (!ReadStringNullTerminated(buffer, tag["mimeType"], false)) { 
     322                WARN("Unable to read string"); 
     323                return false; 
     324        } 
     325 
     326        CHECK_BUFFER_SIZE(buffer, 1); 
     327        tag["pictureType"] = GETIBPOINTER(buffer)[0]; 
     328        buffer.Ignore(1); 
     329 
     330        if (!ReadStringNullTerminated(buffer, tag["description"], unicode)) { 
     331                WARN("Unable to read string"); 
     332                return false; 
     333        } 
     334 
     335        tag["pictureData"] = string((char *) GETIBPOINTER(buffer), 
     336                        GETAVAILABLEBYTESCOUNT(buffer)); 
     337        tag["pictureData"].IsByteArray(true); 
     338 
     339        return true; 
    340340} 
    341341 
    342342bool ID3Parser::ParseCOMM(IOBuffer &buffer, Variant &tag) { 
    343     CHECK_BUFFER_SIZE(buffer, 1); 
    344     bool unicode = GETIBPOINTER(buffer)[0]; 
    345     tag["unicode"] = (bool)unicode != 0; 
    346     buffer.Ignore(1); 
    347  
    348     CHECK_BUFFER_SIZE(buffer, 3); 
    349     if (!ReadStringWithSize(buffer, tag["language"], 3, false)) { 
    350         WARN("Unable to read string"); 
    351         return false; 
    352     } 
    353  
    354     if (!ReadStringNullTerminated(buffer, tag["shortContentDescription"], unicode)) { 
    355         WARN("Unable to read string"); 
    356         return false; 
    357     } 
    358  
    359     if (!ReadStringWithSize(buffer, tag["text"], GETAVAILABLEBYTESCOUNT(buffer), false)) { 
    360         WARN("Unable to read string"); 
    361         return false; 
    362     } 
    363  
    364     return true; 
     343        CHECK_BUFFER_SIZE(buffer, 1); 
     344        bool unicode = GETIBPOINTER(buffer)[0]; 
     345        tag["unicode"] = (bool)unicode != 0; 
     346        buffer.Ignore(1); 
     347 
     348        CHECK_BUFFER_SIZE(buffer, 3); 
     349        if (!ReadStringWithSize(buffer, tag["language"], 3, false)) { 
     350                WARN("Unable to read string"); 
     351                return false; 
     352        } 
     353 
     354        if (!ReadStringNullTerminated(buffer, tag["shortContentDescription"], unicode)) { 
     355                WARN("Unable to read string"); 
     356                return false; 
     357        } 
     358 
     359        if (!ReadStringWithSize(buffer, tag["text"], GETAVAILABLEBYTESCOUNT(buffer), false)) { 
     360                WARN("Unable to read string"); 
     361                return false; 
     362        } 
     363 
     364        return true; 
    365365} 
    366366 
    367367bool ID3Parser::ParseUrlTag(IOBuffer &buffer, Variant &tag) { 
    368     if (!ReadStringWithSize(buffer, tag, GETAVAILABLEBYTESCOUNT(buffer), false)) { 
    369         WARN("Unable to read string"); 
    370         return false; 
    371     } 
    372     return true; 
     368        if (!ReadStringWithSize(buffer, tag, GETAVAILABLEBYTESCOUNT(buffer), false)) { 
     369                WARN("Unable to read string"); 
     370                return false; 
     371        } 
     372        return true; 
    373373} 
    374374 
    375375bool ID3Parser::ParseWXXX(IOBuffer &buffer, Variant &tag) { 
    376     CHECK_BUFFER_SIZE(buffer, 1); 
    377     bool unicode = GETIBPOINTER(buffer)[0]; 
    378     tag["unicode"] = (bool)unicode != 0; 
    379     buffer.Ignore(1); 
    380  
    381     if (!ReadStringNullTerminated(buffer, tag["description"], unicode)) { 
    382         WARN("Unable to read string"); 
    383         return false; 
    384     } 
    385  
    386     if (!ReadStringWithSize(buffer, tag["url"], GETAVAILABLEBYTESCOUNT(buffer), false)) { 
    387         WARN("Unable to read string"); 
    388         return false; 
    389     } 
    390  
    391     return true; 
     376        CHECK_BUFFER_SIZE(buffer, 1); 
     377        bool unicode = GETIBPOINTER(buffer)[0]; 
     378        tag["unicode"] = (bool)unicode != 0; 
     379        buffer.Ignore(1); 
     380 
     381        if (!ReadStringNullTerminated(buffer, tag["description"], unicode)) { 
     382                WARN("Unable to read string"); 
     383                return false; 
     384        } 
     385 
     386        if (!ReadStringWithSize(buffer, tag["url"], GETAVAILABLEBYTESCOUNT(buffer), false)) { 
     387                WARN("Unable to read string"); 
     388                return false; 
     389        } 
     390 
     391        return true; 
    392392} 
    393393 
    394394bool ID3Parser::ParseTXXX(IOBuffer &buffer, Variant &tag) { 
    395     CHECK_BUFFER_SIZE(buffer, 1); 
    396     bool unicode = GETIBPOINTER(buffer)[0]; 
    397     tag["unicode"] = (bool)unicode != 0; 
    398     buffer.Ignore(1); 
    399  
    400     if (!ReadStringNullTerminated(buffer, tag["description"], unicode)) { 
    401         WARN("Unable to read string"); 
    402         return false; 
    403     } 
    404  
    405     if (!ReadStringWithSize(buffer, tag["value"], GETAVAILABLEBYTESCOUNT(buffer), false)) { 
    406         WARN("Unable to read string"); 
    407         return false; 
    408     } 
    409  
    410     return true; 
    411 } 
    412  
     395        CHECK_BUFFER_SIZE(buffer, 1); 
     396        bool unicode = GETIBPOINTER(buffer)[0]; 
     397        tag["unicode"] = (bool)unicode != 0; 
     398        buffer.Ignore(1); 
     399 
     400        if (!ReadStringNullTerminated(buffer, tag["description"], unicode)) { 
     401                WARN("Unable to read string"); 
     402                return false; 
     403        } 
     404 
     405        if (!ReadStringWithSize(buffer, tag["value"], GETAVAILABLEBYTESCOUNT(buffer), false)) { 
     406                WARN("Unable to read string"); 
     407                return false; 
     408        } 
     409 
     410        return true; 
     411} 
     412 
     413#endif /* HAS_MEDIA_MP3 */ 
  • trunk/sources/thelib/src/mediaformats/mp3/mp3document.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
    19  
    20  
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
     19 
     20#ifdef HAS_MEDIA_MP3 
    2121#include "mediaformats/mp3/mp3document.h" 
    2222#include "protocols/baseprotocol.h" 
     
    2828 
    2929int32_t MP3Document::_bitRates[4][4][16] = { 
    30     { //MPEG Version 2.5 
    31         //reserved layer 
    32         {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    33  
    34         //Layer III 
    35         {-1, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 
    36             96000, 112000, 128000, 144000, 160000, -1}, 
    37  
    38         //Layer II 
    39         {-1, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 
    40             96000, 112000, 128000, 144000, 160000, -1}, 
    41  
    42         //Layer I 
    43         {-1, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 
    44             160000, 176000, 192000, 224000, 256000, -1}, 
    45     }, 
    46     { // Reserved 
    47         {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    48         {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    49         {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    50         {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} 
    51     }, 
    52     { //MPEG Version 2 (ISO/IEC 13818-3) 
    53         //reserved layer 
    54         {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    55  
    56         //Layer III 
    57         {-1, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 
    58             96000, 112000, 128000, 144000, 160000, -1}, 
    59  
    60         //Layer II 
    61         {-1, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 
    62             96000, 112000, 128000, 144000, 160000, -1}, 
    63  
    64         //Layer I 
    65         {-1, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 
    66             160000, 176000, 192000, 224000, 256000, -1}, 
    67     }, 
    68     { //MPEG Version 1 (ISO/IEC 11172-3) 
    69         //reserved layer 
    70         {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    71  
    72         //Layer III 
    73         {-1, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 
    74             160000, 192000, 224000, 256000, 320000, -1}, 
    75  
    76         //Layer II 
    77         {-1, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 
    78             160000, 192000, 224000, 256000, 320000, 384000 - 1}, 
    79  
    80         //Layer I 
    81         {-1, 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, 288000, 
    82             320000, 352000, 384000, 416000, 448000 - 1}, 
    83     } 
     30        { //MPEG Version 2.5 
     31                //reserved layer 
     32                {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
     33 
     34                //Layer III 
     35                {-1, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 
     36                        96000, 112000, 128000, 144000, 160000, -1}, 
     37 
     38                //Layer II 
     39                {-1, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 
     40                        96000, 112000, 128000, 144000, 160000, -1}, 
     41 
     42                //Layer I 
     43                {-1, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 
     44                        160000, 176000, 192000, 224000, 256000, -1}, 
     45        }, 
     46        { // Reserved 
     47                {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
     48                {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
     49                {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
     50                {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} 
     51        }, 
     52        { //MPEG Version 2 (ISO/IEC 13818-3) 
     53                //reserved layer 
     54                {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
     55 
     56                //Layer III 
     57                {-1, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 
     58                        96000, 112000, 128000, 144000, 160000, -1}, 
     59 
     60                //Layer II 
     61                {-1, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 
     62                        96000, 112000, 128000, 144000, 160000, -1}, 
     63 
     64                //Layer I 
     65                {-1, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 
     66                        160000, 176000, 192000, 224000, 256000, -1}, 
     67        }, 
     68        { //MPEG Version 1 (ISO/IEC 11172-3) 
     69                //reserved layer 
     70                {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
     71 
     72                //Layer III 
     73                {-1, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 
     74                        160000, 192000, 224000, 256000, 320000, -1}, 
     75 
     76                //Layer II 
     77                {-1, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 
     78                        160000, 192000, 224000, 256000, 320000, 384000 - 1}, 
     79 
     80                //Layer I 
     81                {-1, 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, 288000, 
     82                        320000, 352000, 384000, 416000, 448000 - 1}, 
     83        } 
    8484}; 
    8585 
    8686int32_t MP3Document::_samplingRates[4][4] = { 
    87     {//MPEG Version 2.5 
    88         11025, 12000, 8000, -1 
    89     }, 
    90     {// Reserved 
    91         -1, -1, -1, -1 
    92     }, 
    93     {//MPEG Version 2 (ISO/IEC 13818-3) 
    94         22050, 24000, 16000, -1 
    95     }, 
    96     {//MPEG Version 1 (ISO/IEC 11172-3) 
    97         44100, 48000, 32000, -1 
    98     } 
     87        {//MPEG Version 2.5 
     88                11025, 12000, 8000, -1 
     89        }, 
     90        {// Reserved 
     91                -1, -1, -1, -1 
     92        }, 
     93        {//MPEG Version 2 (ISO/IEC 13818-3) 
     94                22050, 24000, 16000, -1 
     95        }, 
     96        {//MPEG Version 1 (ISO/IEC 11172-3) 
     97                44100, 48000, 32000, -1 
     98        } 
    9999}; 
    100100 
    101101string MP3Document::_versionNames[4] = { 
    102     "MPEG Version 2.5", 
    103     "reserved", 
    104     "MPEG Version 2 (ISO/IEC 13818-3)", 
    105     "MPEG Version 1 (ISO/IEC 11172-3)" 
     102        "MPEG Version 2.5", 
     103        "reserved", 
     104        "MPEG Version 2 (ISO/IEC 13818-3)", 
     105        "MPEG Version 1 (ISO/IEC 11172-3)" 
    106106}; 
    107107string MP3Document::_layerNames[4] = { 
    108     "reserved", 
    109     "Layer III", 
    110     "Layer II", 
    111     "Layer I", 
     108        "reserved", 
     109        "Layer III", 
     110        "Layer II", 
     111        "Layer I", 
    112112}; 
    113113 
     
    123123 
    124124bool MP3Document::ParseDocument() { 
    125     return true; 
     125        return true; 
    126126} 
    127127 
    128128bool MP3Document::BuildFrames() { 
    129     //1. Build the map with frame sizes 
    130     InitFrameSizes(); 
    131  
    132     //2. Go to the beginning of the file 
    133     if (!_mediaFile.SeekBegin()) { 
    134         FATAL("Unable to seek in file"); 
    135         return false; 
    136     } 
    137  
    138     if (!ParseMetadata()) { 
    139         WARN("Invalid metadata"); 
    140         if (!FindFrameData()) { 
    141             FATAL("Unable to position on frame data"); 
    142             return false; 
    143         } 
    144     } 
    145  
    146     uint8_t firstBytes[4]; 
    147  
    148     double totalDuration = 0; 
    149     MediaFrame frame = {0}; 
    150     frame.type = MEDIAFRAME_TYPE_AUDIO; 
    151     frame.isKeyFrame = true; 
    152     frame.deltaTime = 0; 
    153     frame.isBinaryHeader = false; 
    154  
    155     while (_mediaFile.Cursor() != _mediaFile.Size()) { 
    156         //3. Read the first 4 bytes 
    157         if (!_mediaFile.ReadBuffer(firstBytes, 4)) { 
    158             FATAL("Unable to read 4 byte"); 
    159             return false; 
    160         } 
    161  
    162         if ((firstBytes[0] == 0xff) && 
    163                 ((firstBytes[1] >> 5) == 7)) { 
    164             //4. Possible frame. Read the header 
    165             uint8_t version = (firstBytes[1] >> 3)&0x03; 
    166             uint8_t layer = (firstBytes[1] >> 1)&0x03; 
    167             //uint8_t protectBit = firstBytes[1]&0x01; 
    168             uint8_t bitRateIndex = firstBytes[2] >> 4; 
    169             uint8_t sampleRateIndex = (firstBytes[2] >> 2)&0x03; 
    170             uint8_t paddingBit = (firstBytes[2] >> 1)&0x01; 
    171  
    172             //5. get the freame length 
    173             frame.start = _mediaFile.Cursor() - 4; 
    174             frame.length = _frameSizes[version][layer][bitRateIndex] 
    175                     [sampleRateIndex][paddingBit]; 
    176             if (frame.length == 0) { 
    177                 FATAL("Invalid frame length: %d:%d:%d:%d:%d; Cusror: %llx", 
    178                         version, layer, bitRateIndex, sampleRateIndex, 
    179                         paddingBit, _mediaFile.Cursor()); 
    180                 return false; 
    181             } 
    182             //            FINEST("Bytes: %02x %02x %02x %02x; frameStart: 0x%x; frameLength: 0x%x; Layer: %s", 
    183             //                    firstBytes[0], firstBytes[1], firstBytes[2], firstBytes[3], 
    184             //                    frame.start, frame.length, STR(_layerNames[layer])); 
    185  
    186             //6. Compute the frame duration and save the frame start 
    187             uint32_t samplesCount = 0; 
    188             if (layer == LAYER_1) 
    189                 samplesCount = 384; 
    190             else 
    191                 samplesCount = 1152; 
    192             frame.absoluteTime = totalDuration * 1000; 
    193             totalDuration += (double) samplesCount / 
    194                     (double) (_samplingRates[version][sampleRateIndex]); 
    195  
    196             //7. Seek to the next frame 
    197             if (!_mediaFile.SeekTo(frame.start + frame.length)) { 
    198                 WARN("Unable to seek to %llx", frame.start + frame.length); 
    199                 break; 
    200             } 
    201  
    202             //8. All good. Save the frame 
    203             ADD_VECTOR_END(_frames, frame); 
    204         } else { 
    205             //            WARN("Invalid bytes: %02x %02x %02x %02x", 
    206             //                    firstBytes[0], firstBytes[1], firstBytes[2], firstBytes[3]); 
    207             break; 
    208         } 
    209     } 
    210  
    211     //FINEST("totalTime: %f", totalDuration); 
    212  
    213     return true; 
     129        //1. Build the map with frame sizes 
     130        InitFrameSizes(); 
     131 
     132        //2. Go to the beginning of the file 
     133        if (!_mediaFile.SeekBegin()) { 
     134                FATAL("Unable to seek in file"); 
     135                return false; 
     136        } 
     137 
     138        if (!ParseMetadata()) { 
     139                WARN("Invalid metadata"); 
     140                if (!FindFrameData()) { 
     141                        FATAL("Unable to position on frame data"); 
     142                        return false; 
     143                } 
     144        } 
     145 
     146        uint8_t firstBytes[4]; 
     147 
     148        double totalDuration = 0; 
     149        MediaFrame frame = {0}; 
     150        frame.type = MEDIAFRAME_TYPE_AUDIO; 
     151        frame.isKeyFrame = true; 
     152        frame.deltaTime = 0; 
     153        frame.isBinaryHeader = false; 
     154 
     155        while (_mediaFile.Cursor() != _mediaFile.Size()) { 
     156                //3. Read the first 4 bytes 
     157                if (!_mediaFile.ReadBuffer(firstBytes, 4)) { 
     158                        FATAL("Unable to read 4 byte"); 
     159                        return false; 
     160                } 
     161 
     162                if ((firstBytes[0] == 0xff) && 
     163                                ((firstBytes[1] >> 5) == 7)) { 
     164                        //4. Possible frame. Read the header 
     165                        uint8_t version = (firstBytes[1] >> 3)&0x03; 
     166                        uint8_t layer = (firstBytes[1] >> 1)&0x03; 
     167                        //uint8_t protectBit = firstBytes[1]&0x01; 
     168                        uint8_t bitRateIndex = firstBytes[2] >> 4; 
     169                        uint8_t sampleRateIndex = (firstBytes[2] >> 2)&0x03; 
     170                        uint8_t paddingBit = (firstBytes[2] >> 1)&0x01; 
     171 
     172                        //5. get the freame length 
     173                        frame.start = _mediaFile.Cursor() - 4; 
     174                        frame.length = _frameSizes[version][layer][bitRateIndex] 
     175                                        [sampleRateIndex][paddingBit]; 
     176                        if (frame.length == 0) { 
     177                                FATAL("Invalid frame length: %d:%d:%d:%d:%d; Cusror: %llx", 
     178                                                version, layer, bitRateIndex, sampleRateIndex, 
     179                                                paddingBit, _mediaFile.Cursor()); 
     180                                return false; 
     181                        } 
     182                        //            FINEST("Bytes: %02x %02x %02x %02x; frameStart: 0x%x; frameLength: 0x%x; Layer: %s", 
     183                        //                    firstBytes[0], firstBytes[1], firstBytes[2], firstBytes[3], 
     184                        //                    frame.start, frame.length, STR(_layerNames[layer])); 
     185 
     186                        //6. Compute the frame duration and save the frame start 
     187                        uint32_t samplesCount = 0; 
     188                        if (layer == LAYER_1) 
     189                                samplesCount = 384; 
     190                        else 
     191                                samplesCount = 1152; 
     192                        frame.absoluteTime = totalDuration * 1000; 
     193                        totalDuration += (double) samplesCount / 
     194                                        (double) (_samplingRates[version][sampleRateIndex]); 
     195 
     196                        //7. Seek to the next frame 
     197                        if (!_mediaFile.SeekTo(frame.start + frame.length)) { 
     198                                WARN("Unable to seek to %llx", frame.start + frame.length); 
     199                                break; 
     200                        } 
     201 
     202                        //8. All good. Save the frame 
     203                        ADD_VECTOR_END(_frames, frame); 
     204                } else { 
     205                        //            WARN("Invalid bytes: %02x %02x %02x %02x", 
     206                        //                    firstBytes[0], firstBytes[1], firstBytes[2], firstBytes[3]); 
     207                        break; 
     208                } 
     209        } 
     210 
     211        //FINEST("totalTime: %f", totalDuration); 
     212 
     213        return true; 
    214214} 
    215215 
    216216Variant MP3Document::GetRTMPMeta() { 
    217     return _tags; 
     217        return _tags; 
    218218} 
    219219 
    220220bool MP3Document::FindFrameData() { 
    221     if (!_mediaFile.SeekBegin()) { 
    222         FATAL("Unable to seek to the beginning of the file"); 
    223         return false; 
    224     } 
    225  
    226     uint8_t firstBytes[4]; 
    227     while (true) { 
    228         //1. Read the first 4 bytes 
    229         if (!_mediaFile.PeekBuffer(firstBytes, 4)) { 
    230             FATAL("Unable to read 4 bytes"); 
    231             return false; 
    232         } 
    233         if ((firstBytes[0] != 0xff) || ((firstBytes[1] >> 5) != 7)) { 
    234             _mediaFile.SeekAhead(1); 
    235             continue; 
    236         } 
    237  
    238         //2. Split the flags 
    239         uint8_t version = (firstBytes[1] >> 3)&0x03; 
    240         uint8_t layer = (firstBytes[1] >> 1)&0x03; 
    241         //uint8_t protectBit = firstBytes[1]&0x01; 
    242         uint8_t bitRateIndex = firstBytes[2] >> 4; 
    243         uint8_t sampleRateIndex = (firstBytes[2] >> 2)&0x03; 
    244         uint8_t paddingBit = (firstBytes[2] >> 1)&0x01; 
    245  
    246         //3. Compute the frame length from the flags 
    247         uint64_t length = _frameSizes[version][layer][bitRateIndex] 
    248                 [sampleRateIndex][paddingBit]; 
    249         if (length == 0) { 
    250             _mediaFile.SeekAhead(1); 
    251             continue; 
    252         } 
    253  
    254         //4. Save the cursor value and seek ahead to the next frame 
    255         uint64_t cursor = _mediaFile.Cursor(); 
    256         _mediaFile.SeekTo(cursor + length); 
    257  
    258         //5. Try to read 4 bytes again 
    259         if (!_mediaFile.PeekBuffer(firstBytes, 4)) { 
    260             FATAL("Unable to read 4 bytes"); 
    261             return false; 
    262         } 
    263  
    264         //6. Is this a frame start? 
    265         if ((firstBytes[0] != 0xff) || ((firstBytes[1] >> 5) != 7)) { 
    266             _mediaFile.SeekTo(cursor + 1); 
    267             continue; 
    268         } 
    269  
    270         //7. Jack pot! 
    271         return true; 
    272     } 
    273     return false; 
     221        if (!_mediaFile.SeekBegin()) { 
     222                FATAL("Unable to seek to the beginning of the file"); 
     223                return false; 
     224        } 
     225 
     226        uint8_t firstBytes[4]; 
     227        while (true) { 
     228                //1. Read the first 4 bytes 
     229                if (!_mediaFile.PeekBuffer(firstBytes, 4)) { 
     230                        FATAL("Unable to read 4 bytes"); 
     231                        return false; 
     232                } 
     233                if ((firstBytes[0] != 0xff) || ((firstBytes[1] >> 5) != 7)) { 
     234                        _mediaFile.SeekAhead(1); 
     235                        continue; 
     236                } 
     237 
     238                //2. Split the flags 
     239                uint8_t version = (firstBytes[1] >> 3)&0x03; 
     240                uint8_t layer = (firstBytes[1] >> 1)&0x03; 
     241                //uint8_t protectBit = firstBytes[1]&0x01; 
     242                uint8_t bitRateIndex = firstBytes[2] >> 4; 
     243                uint8_t sampleRateIndex = (firstBytes[2] >> 2)&0x03; 
     244                uint8_t paddingBit = (firstBytes[2] >> 1)&0x01; 
     245 
     246                //3. Compute the frame length from the flags 
     247                uint64_t length = _frameSizes[version][layer][bitRateIndex] 
     248                                [sampleRateIndex][paddingBit]; 
     249                if (length == 0) { 
     250                        _mediaFile.SeekAhead(1); 
     251                        continue; 
     252                } 
     253 
     254                //4. Save the cursor value and seek ahead to the next frame 
     255                uint64_t cursor = _mediaFile.Cursor(); 
     256                _mediaFile.SeekTo(cursor + length); 
     257 
     258                //5. Try to read 4 bytes again 
     259                if (!_mediaFile.PeekBuffer(firstBytes, 4)) { 
     260                        FATAL("Unable to read 4 bytes"); 
     261                        return false; 
     262                } 
     263 
     264                //6. Is this a frame start? 
     265                if ((firstBytes[0] != 0xff) || ((firstBytes[1] >> 5) != 7)) { 
     266                        _mediaFile.SeekTo(cursor + 1); 
     267                        continue; 
     268                } 
     269 
     270                //7. Jack pot! 
     271                return true; 
     272        } 
     273        return false; 
    274274} 
    275275 
    276276bool MP3Document::ParseMetadata() { 
    277     //1. pick up first 3 bytes they must be ID3 
    278     uint8_t id3[3]; 
    279     if (!_mediaFile.ReadBuffer(id3, 3)) { 
    280         FATAL("Unable to read 3 bytes"); 
    281         return false; 
    282     } 
    283     if ((id3[0] != 'I') || (id3[1] != 'D') || (id3[2] != '3')) { 
    284         WARN("ID3 not found"); 
    285         return false; 
    286     } 
    287  
    288     //2. pick up the major version 
    289     uint8_t majorVersion; 
    290     uint8_t minorVersion; 
    291     if (!_mediaFile.ReadBuffer(&majorVersion, 1)) { 
    292         FATAL("Unable to read 1 byte"); 
    293         return false; 
    294     } 
    295     if (!_mediaFile.ReadBuffer(&minorVersion, 1)) { 
    296         FATAL("Unable to read 1 byte"); 
    297         return false; 
    298     } 
    299     //FINEST("We have an ID3v%d.%d", majorVersion, minorVersion); 
    300  
    301     //3. Instantiate the proper parser 
    302     ID3Parser *pParser = new ID3Parser(majorVersion, minorVersion); 
    303  
    304     //4. Parse 
    305     bool parseResult = pParser->Parse(_mediaFile); 
    306     _tags["tags"] = pParser->GetMetadata(); 
    307     delete pParser; 
    308     if (!parseResult) { 
    309         return false; 
    310     } 
    311  
    312     //5. Process the metadata 
    313     return true; 
     277        //1. pick up first 3 bytes they must be ID3 
     278        uint8_t id3[3]; 
     279        if (!_mediaFile.ReadBuffer(id3, 3)) { 
     280                FATAL("Unable to read 3 bytes"); 
     281                return false; 
     282        } 
     283        if ((id3[0] != 'I') || (id3[1] != 'D') || (id3[2] != '3')) { 
     284                WARN("ID3 not found"); 
     285                return false; 
     286        } 
     287 
     288        //2. pick up the major version 
     289        uint8_t majorVersion; 
     290        uint8_t minorVersion; 
     291        if (!_mediaFile.ReadBuffer(&majorVersion, 1)) { 
     292                FATAL("Unable to read 1 byte"); 
     293                return false; 
     294        } 
     295        if (!_mediaFile.ReadBuffer(&minorVersion, 1)) { 
     296                FATAL("Unable to read 1 byte"); 
     297                return false; 
     298        } 
     299        //FINEST("We have an ID3v%d.%d", majorVersion, minorVersion); 
     300 
     301        //3. Instantiate the proper parser 
     302        ID3Parser *pParser = new ID3Parser(majorVersion, minorVersion); 
     303 
     304        //4. Parse 
     305        bool parseResult = pParser->Parse(_mediaFile); 
     306        _tags["tags"] = pParser->GetMetadata(); 
     307        delete pParser; 
     308        if (!parseResult) { 
     309                return false; 
     310        } 
     311 
     312        //5. Process the metadata 
     313        return true; 
    314314} 
    315315 
    316316void MP3Document::InitFrameSizes() { 
    317     if (_frameSizes.size() > 0) 
    318         return; 
    319     //ver/layer/bitrate/samplerate/padding 
    320     for (uint8_t ver = 0; ver < 4; ver++) { 
    321         if (ver == 1) 
    322             continue; 
    323         for (uint8_t layer = 0; layer < 4; layer++) { 
    324             if (layer == 0) 
    325                 continue; 
    326             for (uint8_t bitRateIndex = 1; bitRateIndex < 15; bitRateIndex++) { 
    327                 for (uint8_t sampleRateIndex = 0; sampleRateIndex < 3; sampleRateIndex++) { 
    328                     for (uint8_t padding = 0; padding < 2; padding++) { 
    329                         int32_t bitRate = _bitRates[ver][layer][bitRateIndex]; 
    330                         int32_t sampleRate = _samplingRates[ver][sampleRateIndex]; 
    331                         uint32_t length = 0; 
    332                         if (layer == LAYER_1) { 
    333                             length = (12 * bitRate / sampleRate + padding)*4; 
    334                         } else { 
    335                             length = 144 * bitRate / sampleRate + padding; 
    336                         } 
    337                         _frameSizes[ver][layer][bitRateIndex][sampleRateIndex][padding] = length; 
    338                     } 
    339                 } 
    340             } 
    341         } 
    342     } 
    343 } 
    344  
     317        if (_frameSizes.size() > 0) 
     318                return; 
     319        //ver/layer/bitrate/samplerate/padding 
     320        for (uint8_t ver = 0; ver < 4; ver++) { 
     321                if (ver == 1) 
     322                        continue; 
     323                for (uint8_t layer = 0; layer < 4; layer++) { 
     324                        if (layer == 0) 
     325                                continue; 
     326                        for (uint8_t bitRateIndex = 1; bitRateIndex < 15; bitRateIndex++) { 
     327                                for (uint8_t sampleRateIndex = 0; sampleRateIndex < 3; sampleRateIndex++) { 
     328                                        for (uint8_t padding = 0; padding < 2; padding++) { 
     329                                                int32_t bitRate = _bitRates[ver][layer][bitRateIndex]; 
     330                                                int32_t sampleRate = _samplingRates[ver][sampleRateIndex]; 
     331                                                uint32_t length = 0; 
     332                                                if (layer == LAYER_1) { 
     333                                                        length = (12 * bitRate / sampleRate + padding)*4; 
     334                                                } else { 
     335                                                        length = 144 * bitRate / sampleRate + padding; 
     336                                                } 
     337                                                _frameSizes[ver][layer][bitRateIndex][sampleRateIndex][padding] = length; 
     338                                        } 
     339                                } 
     340                        } 
     341                } 
     342        } 
     343} 
     344 
     345#endif /* HAS_MEDIA_MP3 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomavc1.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomavc1.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2525AtomAVC1::AtomAVC1(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2626: VersionedBoxAtom(pDocument, type, size, start) { 
    27     _pAVCC = NULL; 
    28     _reserved = 0; 
    29     _referenceIndex = 0; 
    30     _qtVideoEncodingVersion = 0; 
    31     _qtVideoEncodingRevisionLevel = 0; 
    32     _qtVideoEncodingVendor = 0; 
    33     _qtVideoTemporalQuality = 0; 
    34     _qtVideoSpatialQuality = 0; 
    35     _videoFramePixelSize = 0; 
    36     _horizontalDpi = 0; 
    37     _verticalDpi = 0; 
    38     _qtVideoDataSize = 0; 
    39     _videoFrameCount = 0; 
    40     _videoEncoderNameLength = 0; 
    41     _videoPixelDepth = 0; 
    42     _qtVideoColorTableId = 0; 
     27        _pAVCC = NULL; 
     28        _reserved = 0; 
     29        _referenceIndex = 0; 
     30        _qtVideoEncodingVersion = 0; 
     31        _qtVideoEncodingRevisionLevel = 0; 
     32        _qtVideoEncodingVendor = 0; 
     33        _qtVideoTemporalQuality = 0; 
     34        _qtVideoSpatialQuality = 0; 
     35        _videoFramePixelSize = 0; 
     36        _horizontalDpi = 0; 
     37        _verticalDpi = 0; 
     38        _qtVideoDataSize = 0; 
     39        _videoFrameCount = 0; 
     40        _videoEncoderNameLength = 0; 
     41        _videoPixelDepth = 0; 
     42        _qtVideoColorTableId = 0; 
    4343} 
    4444 
     
    4747 
    4848bool AtomAVC1::ReadData() { 
    49     if (!ReadUInt16(_reserved)) { 
    50         FATAL("Unable to read _reserved"); 
    51         return false; 
    52     } 
    53     //FINEST("_reserved: %u", _reserved); 
     49        if (!ReadUInt16(_reserved)) { 
     50                FATAL("Unable to read _reserved"); 
     51                return false; 
     52        } 
     53        //FINEST("_reserved: %u", _reserved); 
    5454 
    55     if (!ReadUInt16(_referenceIndex)) { 
    56         FATAL("Unable to read _referenceIndex"); 
    57         return false; 
    58     } 
    59     //FINEST("_referenceIndex: %u", _referenceIndex); 
     55        if (!ReadUInt16(_referenceIndex)) { 
     56                FATAL("Unable to read _referenceIndex"); 
     57                return false; 
     58        } 
     59        //FINEST("_referenceIndex: %u", _referenceIndex); 
    6060 
    61     if (!ReadUInt16(_qtVideoEncodingVersion)) { 
    62         FATAL("Unable to read _qtVideoEncodingVersion"); 
    63         return false; 
    64     } 
    65     //FINEST("_qtVideoEncodingVersion: %u", _qtVideoEncodingVersion); 
     61        if (!ReadUInt16(_qtVideoEncodingVersion)) { 
     62                FATAL("Unable to read _qtVideoEncodingVersion"); 
     63                return false; 
     64        } 
     65        //FINEST("_qtVideoEncodingVersion: %u", _qtVideoEncodingVersion); 
    6666 
    67     if (!ReadUInt16(_qtVideoEncodingRevisionLevel)) { 
    68         FATAL("Unable to read _qtVideoEncodingRevisionLevel"); 
    69         return false; 
    70     } 
    71     //FINEST("_qtVideoEncodingRevisionLevel: %u", _qtVideoEncodingRevisionLevel); 
     67        if (!ReadUInt16(_qtVideoEncodingRevisionLevel)) { 
     68                FATAL("Unable to read _qtVideoEncodingRevisionLevel"); 
     69                return false; 
     70        } 
     71        //FINEST("_qtVideoEncodingRevisionLevel: %u", _qtVideoEncodingRevisionLevel); 
    7272 
    73     if (!ReadUInt32(_qtVideoEncodingVendor)) { 
    74         FATAL("Unable to read _qtVideoEncodingVendor"); 
    75         return false; 
    76     } 
    77     //FINEST("_qtVideoEncodingVendor: %u", _qtVideoEncodingVendor); 
     73        if (!ReadUInt32(_qtVideoEncodingVendor)) { 
     74                FATAL("Unable to read _qtVideoEncodingVendor"); 
     75                return false; 
     76        } 
     77        //FINEST("_qtVideoEncodingVendor: %u", _qtVideoEncodingVendor); 
    7878 
    79     if (!ReadUInt32(_qtVideoTemporalQuality)) { 
    80         FATAL("Unable to read _qtVideoTemporalQuality"); 
    81         return false; 
    82     } 
    83     //FINEST("_qtVideoTemporalQuality: %u", _qtVideoTemporalQuality); 
     79        if (!ReadUInt32(_qtVideoTemporalQuality)) { 
     80                FATAL("Unable to read _qtVideoTemporalQuality"); 
     81                return false; 
     82        } 
     83        //FINEST("_qtVideoTemporalQuality: %u", _qtVideoTemporalQuality); 
    8484 
    85     if (!ReadUInt32(_qtVideoSpatialQuality)) { 
    86         FATAL("Unable to read _qtVideoSpatialQuality"); 
    87         return false; 
    88     } 
    89     //FINEST("_qtVideoSpatialQuality: %u", _qtVideoSpatialQuality); 
     85        if (!ReadUInt32(_qtVideoSpatialQuality)) { 
     86                FATAL("Unable to read _qtVideoSpatialQuality"); 
     87                return false; 
     88        } 
     89        //FINEST("_qtVideoSpatialQuality: %u", _qtVideoSpatialQuality); 
    9090 
    91     if (!ReadUInt32(_videoFramePixelSize)) { 
    92         FATAL("Unable to read _videoFramePixelSize"); 
    93         return false; 
    94     } 
    95     //FINEST("_videoFramePixelSize: %u", _videoFramePixelSize); 
     91        if (!ReadUInt32(_videoFramePixelSize)) { 
     92                FATAL("Unable to read _videoFramePixelSize"); 
     93                return false; 
     94        } 
     95        //FINEST("_videoFramePixelSize: %u", _videoFramePixelSize); 
    9696 
    97     if (!ReadUInt32(_horizontalDpi)) { 
    98         FATAL("Unable to read _horizontalDpi"); 
    99         return false; 
    100     } 
    101     //FINEST("_horizontalDpi: %u", _horizontalDpi); 
     97        if (!ReadUInt32(_horizontalDpi)) { 
     98                FATAL("Unable to read _horizontalDpi"); 
     99                return false; 
     100        } 
     101        //FINEST("_horizontalDpi: %u", _horizontalDpi); 
    102102 
    103     if (!ReadUInt32(_verticalDpi)) { 
    104         FATAL("Unable to read _verticalDpi"); 
    105         return false; 
    106     } 
    107     //FINEST("_verticalDpi: %u", _verticalDpi); 
     103        if (!ReadUInt32(_verticalDpi)) { 
     104                FATAL("Unable to read _verticalDpi"); 
     105                return false; 
     106        } 
     107        //FINEST("_verticalDpi: %u", _verticalDpi); 
    108108 
    109     if (!ReadUInt32(_qtVideoDataSize)) { 
    110         FATAL("Unable to read _qtVideoDataSize"); 
    111         return false; 
    112     } 
    113     //FINEST("_qtVideoDataSize: %u", _qtVideoDataSize); 
     109        if (!ReadUInt32(_qtVideoDataSize)) { 
     110                FATAL("Unable to read _qtVideoDataSize"); 
     111                return false; 
     112        } 
     113        //FINEST("_qtVideoDataSize: %u", _qtVideoDataSize); 
    114114 
    115     if (!ReadUInt16(_videoFrameCount)) { 
    116         FATAL("Unable to read _videoFrameCount"); 
    117         return false; 
    118     } 
    119     //FINEST("_videoFrameCount: %u", _videoFrameCount); 
     115        if (!ReadUInt16(_videoFrameCount)) { 
     116                FATAL("Unable to read _videoFrameCount"); 
     117                return false; 
     118        } 
     119        //FINEST("_videoFrameCount: %u", _videoFrameCount); 
    120120 
    121     if (!ReadUInt8(_videoEncoderNameLength)) { 
    122         FATAL("Unable to read _videoEncoderNameLength"); 
    123         return false; 
    124     } 
    125     //FINEST("_videoEncoderNameLength: %u", _videoEncoderNameLength); 
     121        if (!ReadUInt8(_videoEncoderNameLength)) { 
     122                FATAL("Unable to read _videoEncoderNameLength"); 
     123                return false; 
     124        } 
     125        //FINEST("_videoEncoderNameLength: %u", _videoEncoderNameLength); 
    126126 
    127     if (_videoEncoderNameLength < 31) 
    128         _videoEncoderNameLength = 31; 
     127        if (_videoEncoderNameLength < 31) 
     128                _videoEncoderNameLength = 31; 
    129129 
    130     uint8_t *pTemp = new uint8_t[_videoEncoderNameLength]; 
    131     if (!ReadArray(pTemp, _videoEncoderNameLength)) { 
    132         FATAL("Unable to read _videoEncoderNameLength"); 
     130        uint8_t *pTemp = new uint8_t[_videoEncoderNameLength]; 
     131        if (!ReadArray(pTemp, _videoEncoderNameLength)) { 
     132                FATAL("Unable to read _videoEncoderNameLength"); 
     133                delete[] pTemp; 
     134                return false; 
     135        } 
     136        _videoEncoderName = string((char *) pTemp, _videoEncoderNameLength); 
    133137        delete[] pTemp; 
    134         return false; 
    135     } 
    136     _videoEncoderName = string((char *) pTemp, _videoEncoderNameLength); 
    137     delete[] pTemp; 
    138     //FINEST("_videoEncoderName: %s", STR(_videoEncoderName)); 
     138        //FINEST("_videoEncoderName: %s", STR(_videoEncoderName)); 
    139139 
    140     if (!ReadUInt16(_videoPixelDepth)) { 
    141         FATAL("Unable to read _videoPixelDepth"); 
    142         return false; 
    143     } 
    144     //FINEST("_videoPixelDepth: %u", _videoPixelDepth); 
     140        if (!ReadUInt16(_videoPixelDepth)) { 
     141                FATAL("Unable to read _videoPixelDepth"); 
     142                return false; 
     143        } 
     144        //FINEST("_videoPixelDepth: %u", _videoPixelDepth); 
    145145 
    146     if (!ReadUInt16(_qtVideoColorTableId)) { 
    147         FATAL("Unable to read _qtVideoColorTableId"); 
    148         return false; 
    149     } 
    150     //FINEST("_qtVideoColorTableId: %u", _qtVideoColorTableId); 
    151     if (_qtVideoColorTableId != 0xffff) { 
    152         FATAL("_qtVideoColorTableId not supported yet"); 
    153         return false; 
    154     } 
     146        if (!ReadUInt16(_qtVideoColorTableId)) { 
     147                FATAL("Unable to read _qtVideoColorTableId"); 
     148                return false; 
     149        } 
     150        //FINEST("_qtVideoColorTableId: %u", _qtVideoColorTableId); 
     151        if (_qtVideoColorTableId != 0xffff) { 
     152                FATAL("_qtVideoColorTableId not supported yet"); 
     153                return false; 
     154        } 
    155155 
    156     return true; 
     156        return true; 
    157157} 
    158158 
    159159bool AtomAVC1::AtomCreated(BaseAtom *pAtom) { 
    160     switch (pAtom->GetTypeNumeric()) { 
    161             //TODO: What is the deal with all this order stuff!? 
    162         case A_AVCC: 
    163             _pAVCC = (AtomAVCC *) pAtom; 
    164             return true; 
    165         default: 
    166         { 
    167             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    168             return false; 
    169         } 
    170     } 
     160        switch (pAtom->GetTypeNumeric()) { 
     161                        //TODO: What is the deal with all this order stuff!? 
     162                case A_AVCC: 
     163                        _pAVCC = (AtomAVCC *) pAtom; 
     164                        return true; 
     165                default: 
     166                { 
     167                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     168                        return false; 
     169                } 
     170        } 
    171171} 
    172172 
     173#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomavcc.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomavcc.h" 
    2222 
    2323AtomAVCC::AtomAVCC(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2424: BaseAtom(pDocument, type, size, start) { 
    25     _configurationVersion = 0; 
    26     _profile = 0; 
    27     _profileCompatibility = 0; 
    28     _level = 0; 
    29     _naluLengthSize = 0; 
     25        _configurationVersion = 0; 
     26        _profile = 0; 
     27        _profileCompatibility = 0; 
     28        _level = 0; 
     29        _naluLengthSize = 0; 
    3030} 
    3131 
    3232AtomAVCC::~AtomAVCC() { 
    3333 
    34     FOR_VECTOR_ITERATOR(AVCCParameter, _seqParameters, i) { 
    35         if (VECTOR_VAL(i).pData != NULL) 
    36             delete[] VECTOR_VAL(i).pData; 
    37     } 
     34        FOR_VECTOR_ITERATOR(AVCCParameter, _seqParameters, i) { 
     35                if (VECTOR_VAL(i).pData != NULL) 
     36                        delete[] VECTOR_VAL(i).pData; 
     37        } 
    3838 
    39     FOR_VECTOR_ITERATOR(AVCCParameter, _picParameters, i) { 
    40         if (VECTOR_VAL(i).pData != NULL) 
    41             delete[] VECTOR_VAL(i).pData; 
    42     } 
     39        FOR_VECTOR_ITERATOR(AVCCParameter, _picParameters, i) { 
     40                if (VECTOR_VAL(i).pData != NULL) 
     41                        delete[] VECTOR_VAL(i).pData; 
     42        } 
    4343} 
    4444 
    4545uint64_t AtomAVCC::GetExtraDataStart() { 
    46     return _start + 8; 
     46        return _start + 8; 
    4747} 
    4848 
    4949uint64_t AtomAVCC::GetExtraDataLength() { 
    50     return _size - 8; 
     50        return _size - 8; 
    5151} 
    5252 
    5353bool AtomAVCC::Read() { 
    54     uint8_t _seqCount; 
    55     uint8_t _picCount; 
     54        uint8_t _seqCount; 
     55        uint8_t _picCount; 
    5656 
    57     if (!ReadUInt8(_configurationVersion)) { 
    58         FATAL("Unable to read _configurationVersion"); 
    59         return false; 
    60     } 
    61     //FINEST("_configurationVersion: %d", _configurationVersion); 
     57        if (!ReadUInt8(_configurationVersion)) { 
     58                FATAL("Unable to read _configurationVersion"); 
     59                return false; 
     60        } 
     61        //FINEST("_configurationVersion: %d", _configurationVersion); 
    6262 
    63     if (!ReadUInt8(_profile)) { 
    64         FATAL("Unable to read _profile"); 
    65         return false; 
    66     } 
    67     //FINEST("_profile: %d", _profile); 
     63        if (!ReadUInt8(_profile)) { 
     64                FATAL("Unable to read _profile"); 
     65                return false; 
     66        } 
     67        //FINEST("_profile: %d", _profile); 
    6868 
    69     if (!ReadUInt8(_profileCompatibility)) { 
    70         FATAL("Unable to read _profileCompatibility"); 
    71         return false; 
    72     } 
    73     //FINEST("_profileCompatibility: %d", _profileCompatibility); 
     69        if (!ReadUInt8(_profileCompatibility)) { 
     70                FATAL("Unable to read _profileCompatibility"); 
     71                return false; 
     72        } 
     73        //FINEST("_profileCompatibility: %d", _profileCompatibility); 
    7474 
    75     if (!ReadUInt8(_level)) { 
    76         FATAL("Unable to read _level"); 
    77         return false; 
    78     } 
    79     //FINEST("_level: %d", _level); 
     75        if (!ReadUInt8(_level)) { 
     76                FATAL("Unable to read _level"); 
     77                return false; 
     78        } 
     79        //FINEST("_level: %d", _level); 
    8080 
    81     if (!ReadUInt8(_naluLengthSize)) { 
    82         FATAL("Unable to read _naluLengthSize"); 
    83         return false; 
    84     } 
    85     _naluLengthSize = 1 + (_naluLengthSize & 0x03); 
    86     //FINEST("_naluLengthSize: %d", _naluLengthSize); 
     81        if (!ReadUInt8(_naluLengthSize)) { 
     82                FATAL("Unable to read _naluLengthSize"); 
     83                return false; 
     84        } 
     85        _naluLengthSize = 1 + (_naluLengthSize & 0x03); 
     86        //FINEST("_naluLengthSize: %d", _naluLengthSize); 
    8787 
    88     if (!ReadUInt8(_seqCount)) { 
    89         FATAL("Unable to read _seqCount"); 
    90         return false; 
    91     } 
    92     _seqCount = _seqCount & 0x1f; 
    93     //FINEST("_seqCount: %d", _seqCount); 
     88        if (!ReadUInt8(_seqCount)) { 
     89                FATAL("Unable to read _seqCount"); 
     90                return false; 
     91        } 
     92        _seqCount = _seqCount & 0x1f; 
     93        //FINEST("_seqCount: %d", _seqCount); 
    9494 
    95     for (uint8_t i = 0; i < _seqCount; i++) { 
    96         AVCCParameter parameter = {0}; 
     95        for (uint8_t i = 0; i < _seqCount; i++) { 
     96                AVCCParameter parameter = {0}; 
    9797 
    98         if (!ReadUInt16(parameter.size)) { 
    99             FATAL("Unable to read parameter.size"); 
    100             return false; 
    101         } 
    102         //FINEST("parameter.size: %d", parameter.size); 
     98                if (!ReadUInt16(parameter.size)) { 
     99                        FATAL("Unable to read parameter.size"); 
     100                        return false; 
     101                } 
     102                //FINEST("parameter.size: %d", parameter.size); 
    103103 
    104         if (parameter.size > 0) { 
    105             parameter.pData = new uint8_t[parameter.size]; 
    106             if (!ReadArray(parameter.pData, parameter.size)) { 
    107                 FATAL("Unable to read parameter.pData"); 
    108                 return false; 
    109             } 
    110         } 
     104                if (parameter.size > 0) { 
     105                        parameter.pData = new uint8_t[parameter.size]; 
     106                        if (!ReadArray(parameter.pData, parameter.size)) { 
     107                                FATAL("Unable to read parameter.pData"); 
     108                                return false; 
     109                        } 
     110                } 
    111111 
    112         ADD_VECTOR_END(_seqParameters, parameter); 
    113     } 
     112                ADD_VECTOR_END(_seqParameters, parameter); 
     113        } 
    114114 
    115115 
    116116 
    117     if (!ReadUInt8(_picCount)) { 
    118         FATAL("Unable to read _picCount"); 
    119         return false; 
    120     } 
    121     //FINEST("_picCount: %d", _picCount); 
     117        if (!ReadUInt8(_picCount)) { 
     118                FATAL("Unable to read _picCount"); 
     119                return false; 
     120        } 
     121        //FINEST("_picCount: %d", _picCount); 
    122122 
    123     for (uint8_t i = 0; i < _picCount; i++) { 
    124         AVCCParameter parameter = {0}; 
     123        for (uint8_t i = 0; i < _picCount; i++) { 
     124                AVCCParameter parameter = {0}; 
    125125 
    126         if (!ReadUInt16(parameter.size)) { 
    127             FATAL("Unable to read parameter.size"); 
    128             return false; 
    129         } 
    130         //FINEST("parameter.size: %d", parameter.size); 
     126                if (!ReadUInt16(parameter.size)) { 
     127                        FATAL("Unable to read parameter.size"); 
     128                        return false; 
     129                } 
     130                //FINEST("parameter.size: %d", parameter.size); 
    131131 
    132         if (parameter.size > 0) { 
    133             parameter.pData = new uint8_t[parameter.size]; 
    134             if (!ReadArray(parameter.pData, parameter.size)) { 
    135                 FATAL("Unable to read parameter.pData"); 
    136                 return false; 
    137             } 
    138         } 
     132                if (parameter.size > 0) { 
     133                        parameter.pData = new uint8_t[parameter.size]; 
     134                        if (!ReadArray(parameter.pData, parameter.size)) { 
     135                                FATAL("Unable to read parameter.pData"); 
     136                                return false; 
     137                        } 
     138                } 
    139139 
    140         ADD_VECTOR_END(_picParameters, parameter); 
    141     } 
    142     return true; 
     140                ADD_VECTOR_END(_picParameters, parameter); 
     141        } 
     142        return true; 
    143143} 
    144144 
    145145string AtomAVCC::Hierarchy(uint32_t indent) { 
    146     return string(4 * indent, ' ') + GetTypeString(); 
     146        return string(4 * indent, ' ') + GetTypeString(); 
    147147} 
    148148 
    149149 
     150#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomco64.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomco64.h" 
    2222 
     
    3030 
    3131vector<uint64_t> AtomCO64::GetEntries() { 
    32     return _entries; 
     32        return _entries; 
    3333} 
    3434 
    3535bool AtomCO64::ReadData() { 
    36     uint32_t count; 
     36        uint32_t count; 
    3737 
    38     if (!ReadUInt32(count)) { 
    39         FATAL("Unable to read count"); 
    40         return false; 
    41     } 
    42     //FINEST("count: %u", count); 
     38        if (!ReadUInt32(count)) { 
     39                FATAL("Unable to read count"); 
     40                return false; 
     41        } 
     42        //FINEST("count: %u", count); 
    4343 
    44     for (uint32_t i = 0; i < count; i++) { 
    45         uint64_t offset; 
    46         if (!ReadUInt64(offset)) { 
    47             FATAL("Unable to read offset"); 
    48             return false; 
    49         } 
    50         //FINEST("offset[%u]: %u", i, offset); 
    51         ADD_VECTOR_END(_entries, offset); 
    52     } 
    53     return true; 
     44        for (uint32_t i = 0; i < count; i++) { 
     45                uint64_t offset; 
     46                if (!ReadUInt64(offset)) { 
     47                        FATAL("Unable to read offset"); 
     48                        return false; 
     49                } 
     50                //FINEST("offset[%u]: %u", i, offset); 
     51                ADD_VECTOR_END(_entries, offset); 
     52        } 
     53        return true; 
    5454} 
    5555 
    5656 
     57#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomctts.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomctts.h" 
    2222 
     
    3030 
    3131vector<int32_t> AtomCTTS::GetEntries() { 
    32     if (_normalizedEntries.size() != 0) 
    33         return _normalizedEntries; 
     32        if (_normalizedEntries.size() != 0) 
     33                return _normalizedEntries; 
    3434 
    35     FOR_VECTOR_ITERATOR(CTTSEntry, _entries, i) { 
    36         for (uint32_t j = 0; j < VECTOR_VAL(i).sampleCount; j++) { 
    37             ADD_VECTOR_END(_normalizedEntries, VECTOR_VAL(i).sampleOffset); 
    38         } 
    39     } 
    40     return _normalizedEntries; 
     35        FOR_VECTOR_ITERATOR(CTTSEntry, _entries, i) { 
     36                for (uint32_t j = 0; j < VECTOR_VAL(i).sampleCount; j++) { 
     37                        ADD_VECTOR_END(_normalizedEntries, VECTOR_VAL(i).sampleOffset); 
     38                } 
     39        } 
     40        return _normalizedEntries; 
    4141} 
    4242 
    4343bool AtomCTTS::ReadData() { 
    44     uint32_t count; 
    45     if (!ReadUInt32(count)) { 
    46         FATAL("Unable to read count"); 
    47         return false; 
    48     } 
    49     //FINEST("count: %u", count); 
     44        uint32_t count; 
     45        if (!ReadUInt32(count)) { 
     46                FATAL("Unable to read count"); 
     47                return false; 
     48        } 
     49        //FINEST("count: %u", count); 
    5050 
    51     for (uint32_t i = 0; i < count; i++) { 
    52         CTTSEntry entry; 
    53         if (!ReadUInt32(entry.sampleCount)) { 
    54             FATAL("Unable to read sample count"); 
    55             return false; 
    56         } 
     51        for (uint32_t i = 0; i < count; i++) { 
     52                CTTSEntry entry; 
     53                if (!ReadUInt32(entry.sampleCount)) { 
     54                        FATAL("Unable to read sample count"); 
     55                        return false; 
     56                } 
    5757 
    58         if (!ReadInt32(entry.sampleOffset)) { 
    59             FATAL("Unable to read sample offset"); 
    60             return false; 
    61         } 
     58                if (!ReadInt32(entry.sampleOffset)) { 
     59                        FATAL("Unable to read sample offset"); 
     60                        return false; 
     61                } 
    6262 
    63         //        FINEST("sampleCount[%u]: %u; sampleOffset[%u]: %u", i, 
    64         //                entry.sampleCount, i, entry.sampleOffset); 
     63                //        FINEST("sampleCount[%u]: %u; sampleOffset[%u]: %u", i, 
     64                //                entry.sampleCount, i, entry.sampleOffset); 
    6565 
    66         ADD_VECTOR_END(_entries, entry); 
    67     } 
    68     return true; 
     66                ADD_VECTOR_END(_entries, entry); 
     67        } 
     68        return true; 
    6969} 
    7070 
     71#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomdata.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomdata.h" 
    2222 
     
    3030 
    3131Variant AtomDATA::GetVariant() { 
    32     switch (_type) { 
    33         case 1: 
    34         { 
    35             //Single string 
    36             return _dataString; 
    37         } 
    38         case 0: 
    39         { 
    40             //many uint16_t 
    41             Variant result; 
     32        switch (_type) { 
     33                case 1: 
     34                { 
     35                        //Single string 
     36                        return _dataString; 
     37                } 
     38                case 0: 
     39                { 
     40                        //many uint16_t 
     41                        Variant result; 
    4242 
    43             FOR_VECTOR(_dataUI16, i) { 
    44                 result[i] = _dataUI16[i]; 
    45             } 
    46             result.IsArray(true); 
    47             return result; 
    48         } 
    49         case 21: 
    50         { 
    51             //many uint8_t 
    52             Variant result; 
     43                        FOR_VECTOR(_dataUI16, i) { 
     44                                result[i] = _dataUI16[i]; 
     45                        } 
     46                        result.IsArray(true); 
     47                        return result; 
     48                } 
     49                case 21: 
     50                { 
     51                        //many uint8_t 
     52                        Variant result; 
    5353 
    54             FOR_VECTOR(_dataUI8, i) { 
    55                 result[i] = _dataUI8[i]; 
    56             } 
    57             result.IsArray(true); 
    58             return result; 
    59         } 
    60         case 14: 
    61         case 15: 
    62         { 
    63             //jpg/png image data 
    64             Variant result = _dataImg; 
    65             result.IsByteArray(true); 
    66             return result; 
    67             //TODO: for now, return null 
    68             //return Variant(); 
    69         } 
    70         default: 
    71         { 
    72             FATAL("Type %d not yet implemented", _type); 
    73             return false; 
    74         } 
    75     } 
     54                        FOR_VECTOR(_dataUI8, i) { 
     55                                result[i] = _dataUI8[i]; 
     56                        } 
     57                        result.IsArray(true); 
     58                        return result; 
     59                } 
     60                case 14: 
     61                case 15: 
     62                { 
     63                        //jpg/png image data 
     64                        Variant result = _dataImg; 
     65                        result.IsByteArray(true); 
     66                        return result; 
     67                        //TODO: for now, return null 
     68                        //return Variant(); 
     69                } 
     70                default: 
     71                { 
     72                        FATAL("Type %d not yet implemented", _type); 
     73                        return false; 
     74                } 
     75        } 
    7676} 
    7777 
    7878bool AtomDATA::Read() { 
    79     //1. Read the type 
    80     if (!ReadUInt32(_type)) { 
    81         FATAL("Unable to read type"); 
    82         return false; 
    83     } 
    84     //FINEST("_type: %d", _type); 
     79        //1. Read the type 
     80        if (!ReadUInt32(_type)) { 
     81                FATAL("Unable to read type"); 
     82                return false; 
     83        } 
     84        //FINEST("_type: %d", _type); 
    8585 
    86     //2. Read unknown 4 bytes 
    87     if (!ReadUInt32(_unknown)) { 
    88         FATAL("Unable to read type"); 
    89         return false; 
    90     } 
    91     //FINEST("_unknown: %d", _unknown); 
     86        //2. Read unknown 4 bytes 
     87        if (!ReadUInt32(_unknown)) { 
     88                FATAL("Unable to read type"); 
     89                return false; 
     90        } 
     91        //FINEST("_unknown: %d", _unknown); 
    9292 
    93     switch (_type) { 
    94         case 1: 
    95         { 
    96             //Single string 
    97             if (!ReadString(_dataString, GetSize() - 8 - 8)) { 
    98                 FATAL("Unable to read string"); 
    99                 return false; 
    100             } 
    101             //FINEST("String: %s", STR(_dataString)); 
    102             return true; 
    103         } 
    104         case 0: 
    105         { 
    106             //many uint16_t 
    107             uint64_t count = (GetSize() - 8 - 8) / 2; 
    108             for (uint64_t i = 0; i < count; i++) { 
    109                 uint16_t val; 
    110                 if (!ReadUInt16(val)) { 
    111                     FATAL("Unable to read value"); 
    112                     return false; 
    113                 } 
    114                 ADD_VECTOR_END(_dataUI16, val); 
    115             } 
    116             return true; 
    117         } 
    118         case 21: 
    119         { 
    120             //many uint8_t 
    121             uint64_t count = GetSize() - 8 - 8; 
    122             for (uint64_t i = 0; i < count; i++) { 
    123                 uint8_t val; 
    124                 if (!ReadUInt8(val)) { 
    125                     FATAL("Unable to read value"); 
    126                     return false; 
    127                 } 
    128                 ADD_VECTOR_END(_dataUI8, val); 
    129             } 
    130             return true; 
    131         } 
    132         case 14: 
    133         case 15: 
    134         { 
    135             if (!ReadString(_dataImg, GetSize() - 8 - 8)) { 
    136                 FATAL("Unable to read data"); 
    137                 return false; 
    138             } 
    139             return true; 
    140         } 
    141         default: 
    142         { 
    143             FATAL("Type %d not yet implemented", _type); 
    144             return false; 
    145         } 
    146     } 
     93        switch (_type) { 
     94                case 1: 
     95                { 
     96                        //Single string 
     97                        if (!ReadString(_dataString, GetSize() - 8 - 8)) { 
     98                                FATAL("Unable to read string"); 
     99                                return false; 
     100                        } 
     101                        //FINEST("String: %s", STR(_dataString)); 
     102                        return true; 
     103                } 
     104                case 0: 
     105                { 
     106                        //many uint16_t 
     107                        uint64_t count = (GetSize() - 8 - 8) / 2; 
     108                        for (uint64_t i = 0; i < count; i++) { 
     109                                uint16_t val; 
     110                                if (!ReadUInt16(val)) { 
     111                                        FATAL("Unable to read value"); 
     112                                        return false; 
     113                                } 
     114                                ADD_VECTOR_END(_dataUI16, val); 
     115                        } 
     116                        return true; 
     117                } 
     118                case 21: 
     119                { 
     120                        //many uint8_t 
     121                        uint64_t count = GetSize() - 8 - 8; 
     122                        for (uint64_t i = 0; i < count; i++) { 
     123                                uint8_t val; 
     124                                if (!ReadUInt8(val)) { 
     125                                        FATAL("Unable to read value"); 
     126                                        return false; 
     127                                } 
     128                                ADD_VECTOR_END(_dataUI8, val); 
     129                        } 
     130                        return true; 
     131                } 
     132                case 14: 
     133                case 15: 
     134                { 
     135                        if (!ReadString(_dataImg, GetSize() - 8 - 8)) { 
     136                                FATAL("Unable to read data"); 
     137                                return false; 
     138                        } 
     139                        return true; 
     140                } 
     141                default: 
     142                { 
     143                        FATAL("Type %d not yet implemented", _type); 
     144                        return false; 
     145                } 
     146        } 
    147147} 
    148148 
    149149std::string AtomDATA::Hierarchy(uint32_t indent) { 
    150     return std::string(4 * indent, ' ') + GetTypeString(); 
     150        return std::string(4 * indent, ' ') + GetTypeString(); 
    151151} 
    152152 
    153153 
     154#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomdinf.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomdinf.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2424AtomDINF::AtomDINF(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2525: BoxAtom(pDocument, type, size, start) { 
    26     _pDREF = NULL; 
     26        _pDREF = NULL; 
    2727} 
    2828 
     
    3131 
    3232bool AtomDINF::AtomCreated(BaseAtom *pAtom) { 
    33     switch (pAtom->GetTypeNumeric()) { 
    34         case A_DREF: 
    35             _pDREF = (AtomDREF *) pAtom; 
    36             return true; 
    37         default: 
    38         { 
    39             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    40             return false; 
    41         } 
    42     } 
     33        switch (pAtom->GetTypeNumeric()) { 
     34                case A_DREF: 
     35                        _pDREF = (AtomDREF *) pAtom; 
     36                        return true; 
     37                default: 
     38                { 
     39                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     40                        return false; 
     41                } 
     42        } 
    4343} 
    4444 
    4545 
     46#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomdref.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomdref.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    3030 
    3131bool AtomDREF::ReadData() { 
    32     uint32_t count; 
    33     if (!ReadUInt32(count)) { 
    34         FATAL("Unable to read count"); 
    35         return false; 
    36     } 
    37     return true; 
     32        uint32_t count; 
     33        if (!ReadUInt32(count)) { 
     34                FATAL("Unable to read count"); 
     35                return false; 
     36        } 
     37        return true; 
    3838} 
    3939 
    4040bool AtomDREF::AtomCreated(BaseAtom *pAtom) { 
    41     switch (pAtom->GetTypeNumeric()) { 
    42         case A_URL: 
    43             ADD_VECTOR_END(_urls, (AtomURL *) pAtom); 
    44             return true; 
    45         default: 
    46         { 
    47             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    48             return false; 
    49         } 
    50     } 
     41        switch (pAtom->GetTypeNumeric()) { 
     42                case A_URL: 
     43                        ADD_VECTOR_END(_urls, (AtomURL *) pAtom); 
     44                        return true; 
     45                default: 
     46                { 
     47                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     48                        return false; 
     49                } 
     50        } 
    5151} 
    5252 
     53#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomesds.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
    19  
    20  
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
     19 
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomesds.h" 
    2222#include "buffering/bitarray.h" 
     
    2929AtomESDS::AtomESDS(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    3030: VersionedAtom(pDocument, type, size, start) { 
    31     _MP4ESDescrTag_ID = 0; 
    32     _MP4ESDescrTag_Priority = 0; 
    33     _MP4DecConfigDescrTag_ObjectTypeID = 0; 
    34     _MP4DecConfigDescrTag_StreamType = 0; 
    35     _MP4DecConfigDescrTag_BufferSizeDB = 0; 
    36     _MP4DecConfigDescrTag_MaxBitRate = 0; 
    37     _MP4DecConfigDescrTag_AvgBitRate = 0; 
    38     _extraDataStart = 0; 
    39     _extraDataLength = 0; 
     31        _MP4ESDescrTag_ID = 0; 
     32        _MP4ESDescrTag_Priority = 0; 
     33        _MP4DecConfigDescrTag_ObjectTypeID = 0; 
     34        _MP4DecConfigDescrTag_StreamType = 0; 
     35        _MP4DecConfigDescrTag_BufferSizeDB = 0; 
     36        _MP4DecConfigDescrTag_MaxBitRate = 0; 
     37        _MP4DecConfigDescrTag_AvgBitRate = 0; 
     38        _extraDataStart = 0; 
     39        _extraDataLength = 0; 
    4040#ifdef DEBUG_ESDS_ATOM 
    41     _objectType = 0; 
    42     _sampleRate = 0; 
    43     _channels = 0; 
    44     _extObjectType = 0; 
    45     _sbr = 0; 
    46     _extSampleRate = 0; 
     41        _objectType = 0; 
     42        _sampleRate = 0; 
     43        _channels = 0; 
     44        _extObjectType = 0; 
     45        _sbr = 0; 
     46        _extSampleRate = 0; 
    4747#endif /* DEBUG_ESDS_ATOM */ 
    4848} 
     
    5252 
    5353uint64_t AtomESDS::GetExtraDataStart() { 
    54     return _extraDataStart; 
     54        return _extraDataStart; 
    5555} 
    5656 
    5757uint64_t AtomESDS::GetExtraDataLength() { 
    58     return _extraDataLength; 
     58        return _extraDataLength; 
    5959} 
    6060 
    6161bool AtomESDS::ReadTagLength(uint32_t &length) { 
    62     length = 0; 
    63     uint32_t count = 4; 
    64     while (count--) { 
    65         uint8_t c = 0; 
    66         if (!ReadUInt8(c)) 
    67             return false; 
    68  
    69         length = (length << 7) | (c & 0x7f); 
    70         if (!(c & 0x80)) 
    71             break; 
    72     } 
    73     return true; 
     62        length = 0; 
     63        uint32_t count = 4; 
     64        while (count--) { 
     65                uint8_t c = 0; 
     66                if (!ReadUInt8(c)) 
     67                        return false; 
     68 
     69                length = (length << 7) | (c & 0x7f); 
     70                if (!(c & 0x80)) 
     71                        break; 
     72        } 
     73        return true; 
    7474} 
    7575 
    7676bool AtomESDS::ReadTagAndLength(uint8_t &tagType, uint32_t &length) { 
    77     if (!ReadUInt8(tagType)) 
    78         return false; 
    79     if (!ReadTagLength(length)) 
    80         return false; 
    81     FINEST_ESDS_ATOM("tagType: %d; length: %x; currentPos: %llx", 
    82             tagType, length, CurrentPosition()); 
    83     return true; 
     77        if (!ReadUInt8(tagType)) 
     78                return false; 
     79        if (!ReadTagLength(length)) 
     80                return false; 
     81        FINEST_ESDS_ATOM("tagType: %d; length: %x; currentPos: %llx", 
     82                        tagType, length, CurrentPosition()); 
     83        return true; 
    8484} 
    8585 
    8686bool AtomESDS::ReadData() { 
    87     uint8_t tagType = 0; 
    88     uint32_t length = 0; 
    89  
    90     FINEST_ESDS_ATOM("Position: %llx", CurrentPosition()); 
    91     if (!ReadTagAndLength(tagType, length)) { 
    92         FATAL("Unable to read tag type and length"); 
    93         return false; 
    94     } 
    95  
    96     if (tagType == MP4ESDescrTag) { 
    97         if (!ReadUInt16(_MP4ESDescrTag_ID)) { 
    98             FATAL("Unable to read _MP4ESDescrTag_ID"); 
    99             return false; 
    100         } 
    101         FINEST_ESDS_ATOM("_MP4ESDescrTag_ID: %u", _MP4ESDescrTag_ID); 
    102  
    103         if (!ReadUInt8(_MP4ESDescrTag_Priority)) { 
    104             FATAL("Unable to read _MP4ESDescrTag_Priority"); 
    105             return false; 
    106         } 
    107         FINEST_ESDS_ATOM("_MP4ESDescrTag_Priority: %u", _MP4ESDescrTag_Priority); 
    108     } else { 
    109         if (!ReadUInt16(_MP4ESDescrTag_ID)) { 
    110             FATAL("Unable to read _MP4ESDescrTag_ID"); 
    111             return false; 
    112         } 
    113         FINEST_ESDS_ATOM("_MP4ESDescrTag_ID: %u", _MP4ESDescrTag_ID); 
    114     } 
    115  
    116     FINEST_ESDS_ATOM("Position: %llx", CurrentPosition()); 
    117     if (!ReadTagAndLength(tagType, length)) { 
    118         FATAL("Unable to read tag type and length"); 
    119         return false; 
    120     } 
    121  
    122     if (tagType == MP4DecConfigDescrTag) { 
    123         if (!ReadUInt8(_MP4DecConfigDescrTag_ObjectTypeID)) { 
    124             FATAL("Unable to read _MP4DecConfigDescrTag_ObjectTypeID"); 
    125             return false; 
    126         } 
    127         FINEST_ESDS_ATOM("_MP4DecConfigDescrTag_ObjectTypeID: %u", 
    128                 _MP4DecConfigDescrTag_ObjectTypeID); 
    129  
    130         if (!ReadUInt8(_MP4DecConfigDescrTag_StreamType)) { 
    131             FATAL("Unable to read _MP4DecConfigDescrTag_StreamType"); 
    132             return false; 
    133         } 
    134         FINEST_ESDS_ATOM("_MP4DecConfigDescrTag_StreamType: %u", 
    135                 _MP4DecConfigDescrTag_StreamType); 
    136  
    137         if (!ReadUInt24(_MP4DecConfigDescrTag_BufferSizeDB)) { 
    138             FATAL("Unable to read _MP4DecConfigDescrTag_BufferSizeDB"); 
    139             return false; 
    140         } 
    141         FINEST_ESDS_ATOM("_MP4DecConfigDescrTag_BufferSizeDB: %u", 
    142                 _MP4DecConfigDescrTag_BufferSizeDB); 
    143  
    144         if (!ReadUInt32(_MP4DecConfigDescrTag_MaxBitRate)) { 
    145             FATAL("Unable to read _MP4DecConfigDescrTag_MaxBitRate"); 
    146             return false; 
    147         } 
    148         FINEST_ESDS_ATOM("_MP4DecConfigDescrTag_MaxBitRate: %u", 
    149                 _MP4DecConfigDescrTag_MaxBitRate); 
    150  
    151         if (!ReadUInt32(_MP4DecConfigDescrTag_AvgBitRate)) { 
    152             FATAL("Unable to read _MP4DecConfigDescrTag_AvgBitRate"); 
    153             return false; 
    154         } 
    155         FINEST_ESDS_ATOM("_MP4DecConfigDescrTag_AvgBitRate: %u", 
    156                 _MP4DecConfigDescrTag_AvgBitRate); 
    157  
    158         FINEST_ESDS_ATOM("Position: %llx", CurrentPosition()); 
    159         if (!ReadTagAndLength(tagType, length)) { 
    160             FATAL("Unable to read tag type and length"); 
    161             return false; 
    162         } 
    163  
    164         if (tagType == MP4UnknownTag) { 
    165             uint8_t unknownValue; 
    166             if (!ReadUInt8(unknownValue)) { 
    167                 FATAL("Unable to read unknownValue"); 
    168                 return false; 
    169             } 
    170             FINEST_ESDS_ATOM("unknownValue: %u", unknownValue); 
    171  
    172             FINEST_ESDS_ATOM("Position: %llx", CurrentPosition()); 
    173             if (!ReadTagAndLength(tagType, length)) { 
    174                 FATAL("Unable to read tag type and length"); 
    175                 return false; 
    176             } 
    177         } 
    178  
    179         if (tagType == MP4DecSpecificDescrTag) { 
    180             //iso14496-3 
    181             //http://wiki.multimedia.cx/index.php?title=MPEG-4_Audio 
    182             _extraDataStart = CurrentPosition(); 
    183             _extraDataLength = length; 
     87        uint8_t tagType = 0; 
     88        uint32_t length = 0; 
     89 
     90        FINEST_ESDS_ATOM("Position: %llx", CurrentPosition()); 
     91        if (!ReadTagAndLength(tagType, length)) { 
     92                FATAL("Unable to read tag type and length"); 
     93                return false; 
     94        } 
     95 
     96        if (tagType == MP4ESDescrTag) { 
     97                if (!ReadUInt16(_MP4ESDescrTag_ID)) { 
     98                        FATAL("Unable to read _MP4ESDescrTag_ID"); 
     99                        return false; 
     100                } 
     101                FINEST_ESDS_ATOM("_MP4ESDescrTag_ID: %u", _MP4ESDescrTag_ID); 
     102 
     103                if (!ReadUInt8(_MP4ESDescrTag_Priority)) { 
     104                        FATAL("Unable to read _MP4ESDescrTag_Priority"); 
     105                        return false; 
     106                } 
     107                FINEST_ESDS_ATOM("_MP4ESDescrTag_Priority: %u", _MP4ESDescrTag_Priority); 
     108        } else { 
     109                if (!ReadUInt16(_MP4ESDescrTag_ID)) { 
     110                        FATAL("Unable to read _MP4ESDescrTag_ID"); 
     111                        return false; 
     112                } 
     113                FINEST_ESDS_ATOM("_MP4ESDescrTag_ID: %u", _MP4ESDescrTag_ID); 
     114        } 
     115 
     116        FINEST_ESDS_ATOM("Position: %llx", CurrentPosition()); 
     117        if (!ReadTagAndLength(tagType, length)) { 
     118                FATAL("Unable to read tag type and length"); 
     119                return false; 
     120        } 
     121 
     122        if (tagType == MP4DecConfigDescrTag) { 
     123                if (!ReadUInt8(_MP4DecConfigDescrTag_ObjectTypeID)) { 
     124                        FATAL("Unable to read _MP4DecConfigDescrTag_ObjectTypeID"); 
     125                        return false; 
     126                } 
     127                FINEST_ESDS_ATOM("_MP4DecConfigDescrTag_ObjectTypeID: %u", 
     128                                _MP4DecConfigDescrTag_ObjectTypeID); 
     129 
     130                if (!ReadUInt8(_MP4DecConfigDescrTag_StreamType)) { 
     131                        FATAL("Unable to read _MP4DecConfigDescrTag_StreamType"); 
     132                        return false; 
     133                } 
     134                FINEST_ESDS_ATOM("_MP4DecConfigDescrTag_StreamType: %u", 
     135                                _MP4DecConfigDescrTag_StreamType); 
     136 
     137                if (!ReadUInt24(_MP4DecConfigDescrTag_BufferSizeDB)) { 
     138                        FATAL("Unable to read _MP4DecConfigDescrTag_BufferSizeDB"); 
     139                        return false; 
     140                } 
     141                FINEST_ESDS_ATOM("_MP4DecConfigDescrTag_BufferSizeDB: %u", 
     142                                _MP4DecConfigDescrTag_BufferSizeDB); 
     143 
     144                if (!ReadUInt32(_MP4DecConfigDescrTag_MaxBitRate)) { 
     145                        FATAL("Unable to read _MP4DecConfigDescrTag_MaxBitRate"); 
     146                        return false; 
     147                } 
     148                FINEST_ESDS_ATOM("_MP4DecConfigDescrTag_MaxBitRate: %u", 
     149                                _MP4DecConfigDescrTag_MaxBitRate); 
     150 
     151                if (!ReadUInt32(_MP4DecConfigDescrTag_AvgBitRate)) { 
     152                        FATAL("Unable to read _MP4DecConfigDescrTag_AvgBitRate"); 
     153                        return false; 
     154                } 
     155                FINEST_ESDS_ATOM("_MP4DecConfigDescrTag_AvgBitRate: %u", 
     156                                _MP4DecConfigDescrTag_AvgBitRate); 
     157 
     158                FINEST_ESDS_ATOM("Position: %llx", CurrentPosition()); 
     159                if (!ReadTagAndLength(tagType, length)) { 
     160                        FATAL("Unable to read tag type and length"); 
     161                        return false; 
     162                } 
     163 
     164                if (tagType == MP4UnknownTag) { 
     165                        uint8_t unknownValue; 
     166                        if (!ReadUInt8(unknownValue)) { 
     167                                FATAL("Unable to read unknownValue"); 
     168                                return false; 
     169                        } 
     170                        FINEST_ESDS_ATOM("unknownValue: %u", unknownValue); 
     171 
     172                        FINEST_ESDS_ATOM("Position: %llx", CurrentPosition()); 
     173                        if (!ReadTagAndLength(tagType, length)) { 
     174                                FATAL("Unable to read tag type and length"); 
     175                                return false; 
     176                        } 
     177                } 
     178 
     179                if (tagType == MP4DecSpecificDescrTag) { 
     180                        //iso14496-3 
     181                        //http://wiki.multimedia.cx/index.php?title=MPEG-4_Audio 
     182                        _extraDataStart = CurrentPosition(); 
     183                        _extraDataLength = length; 
    184184#ifdef DEBUG_ESDS_ATOM 
    185             vector<string> sampleRates; 
    186             ADD_VECTOR_END(sampleRates, "96000"); 
    187             ADD_VECTOR_END(sampleRates, "88200"); 
    188             ADD_VECTOR_END(sampleRates, "64000"); 
    189             ADD_VECTOR_END(sampleRates, "48000"); 
    190             ADD_VECTOR_END(sampleRates, "44100"); 
    191             ADD_VECTOR_END(sampleRates, "32000"); 
    192             ADD_VECTOR_END(sampleRates, "24000"); 
    193             ADD_VECTOR_END(sampleRates, "22050"); 
    194             ADD_VECTOR_END(sampleRates, "16000"); 
    195             ADD_VECTOR_END(sampleRates, "12000"); 
    196             ADD_VECTOR_END(sampleRates, "11025"); 
    197             ADD_VECTOR_END(sampleRates, "8000"); 
    198             ADD_VECTOR_END(sampleRates, "7350"); 
    199  
    200             uint8_t *pBuffer = new uint8_t[length]; 
    201             if (!ReadArray(pBuffer, length)) { 
    202                 FATAL("Unable to read the extra data buffer"); 
    203                 return false; 
    204             } 
    205  
    206             BitArray ba; 
    207             ba.Put(pBuffer, length); 
    208             FINEST_ESDS_ATOM("ba:\n%s", STR(ba)); 
    209             delete [] pBuffer; 
    210  
    211             _objectType = ba.ReadBits<uint8_t > (5); 
    212             FINEST_ESDS_ATOM("_objectType: %d", _objectType); 
    213  
    214             _sampleRate = ba.ReadBits<uint8_t > (4); 
    215             FINEST_ESDS_ATOM("_sampleRate: %d; %s", _sampleRate, STR(sampleRates[_sampleRate])); 
    216  
    217             _channels = ba.ReadBits<uint8_t > (4); 
    218             FINEST_ESDS_ATOM("_channels: %d", _channels); 
    219  
    220             while (ba.AvailableBits() >= 11) { 
    221                 if (ba.PeekBits<uint16_t > (11) == 0x2b7) { 
    222                     ba.IgnoreBits(11); 
    223  
    224                     _extObjectType = ba.ReadBits<uint8_t > (5); 
    225                     FINEST_ESDS_ATOM("_extObjectType: %d", _extObjectType); 
    226  
    227                     _sbr = ba.ReadBits<uint8_t > (1); 
    228                     FINEST_ESDS_ATOM("_sbr: %d", _sbr); 
    229  
    230                     _extSampleRate = ba.ReadBits<uint8_t > (4); 
    231                     FINEST_ESDS_ATOM("_extSampleRate: %d; %s", _extSampleRate, STR(sampleRates[_extSampleRate])); 
    232  
    233                     FINEST_ESDS_ATOM("leftovers bits count: %d", ba.AvailableBits()); 
    234  
    235                     break; 
    236                 } else { 
    237                     ba.IgnoreBits(1); 
    238                 } 
    239             } 
     185                        vector<string> sampleRates; 
     186                        ADD_VECTOR_END(sampleRates, "96000"); 
     187                        ADD_VECTOR_END(sampleRates, "88200"); 
     188                        ADD_VECTOR_END(sampleRates, "64000"); 
     189                        ADD_VECTOR_END(sampleRates, "48000"); 
     190                        ADD_VECTOR_END(sampleRates, "44100"); 
     191                        ADD_VECTOR_END(sampleRates, "32000"); 
     192                        ADD_VECTOR_END(sampleRates, "24000"); 
     193                        ADD_VECTOR_END(sampleRates, "22050"); 
     194                        ADD_VECTOR_END(sampleRates, "16000"); 
     195                        ADD_VECTOR_END(sampleRates, "12000"); 
     196                        ADD_VECTOR_END(sampleRates, "11025"); 
     197                        ADD_VECTOR_END(sampleRates, "8000"); 
     198                        ADD_VECTOR_END(sampleRates, "7350"); 
     199 
     200                        uint8_t *pBuffer = new uint8_t[length]; 
     201                        if (!ReadArray(pBuffer, length)) { 
     202                                FATAL("Unable to read the extra data buffer"); 
     203                                return false; 
     204                        } 
     205 
     206                        BitArray ba; 
     207                        ba.Put(pBuffer, length); 
     208                        FINEST_ESDS_ATOM("ba:\n%s", STR(ba)); 
     209                        delete [] pBuffer; 
     210 
     211                        _objectType = ba.ReadBits<uint8_t > (5); 
     212                        FINEST_ESDS_ATOM("_objectType: %d", _objectType); 
     213 
     214                        _sampleRate = ba.ReadBits<uint8_t > (4); 
     215                        FINEST_ESDS_ATOM("_sampleRate: %d; %s", _sampleRate, STR(sampleRates[_sampleRate])); 
     216 
     217                        _channels = ba.ReadBits<uint8_t > (4); 
     218                        FINEST_ESDS_ATOM("_channels: %d", _channels); 
     219 
     220                        while (ba.AvailableBits() >= 11) { 
     221                                if (ba.PeekBits<uint16_t > (11) == 0x2b7) { 
     222                                        ba.IgnoreBits(11); 
     223 
     224                                        _extObjectType = ba.ReadBits<uint8_t > (5); 
     225                                        FINEST_ESDS_ATOM("_extObjectType: %d", _extObjectType); 
     226 
     227                                        _sbr = ba.ReadBits<uint8_t > (1); 
     228                                        FINEST_ESDS_ATOM("_sbr: %d", _sbr); 
     229 
     230                                        _extSampleRate = ba.ReadBits<uint8_t > (4); 
     231                                        FINEST_ESDS_ATOM("_extSampleRate: %d; %s", _extSampleRate, STR(sampleRates[_extSampleRate])); 
     232 
     233                                        FINEST_ESDS_ATOM("leftovers bits count: %d", ba.AvailableBits()); 
     234 
     235                                        break; 
     236                                } else { 
     237                                        ba.IgnoreBits(1); 
     238                                } 
     239                        } 
    240240#endif /* DEBUG_ESDS_ATOM */ 
    241241 
    242             //NYIA; 
    243             return SkipRead(false); 
    244         } 
    245     } 
    246     FATAL("No MP4DecSpecificDescrTag found"); 
    247     return false; 
    248 } 
    249  
     242                        //NYIA; 
     243                        return SkipRead(false); 
     244                } 
     245        } 
     246        FATAL("No MP4DecSpecificDescrTag found"); 
     247        return false; 
     248} 
     249 
     250#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomftyp.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomftyp.h" 
    2222 
    2323AtomFTYP::AtomFTYP(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2424: BaseAtom(pDocument, type, size, start) { 
    25     _majorBrand = 0; 
    26     _minorVersion = 0; 
     25        _majorBrand = 0; 
     26        _minorVersion = 0; 
    2727} 
    2828 
     
    3131 
    3232bool AtomFTYP::Read() { 
    33     if (!ReadUInt32(_majorBrand, false)) { 
    34         FATAL("Unable to read major brand"); 
    35         return false; 
    36     } 
    37     //FINEST("_majorBrand: %s(%u)", STR(U32TOS(_majorBrand)), _majorBrand); 
     33        if (!ReadUInt32(_majorBrand, false)) { 
     34                FATAL("Unable to read major brand"); 
     35                return false; 
     36        } 
     37        //FINEST("_majorBrand: %s(%u)", STR(U32TOS(_majorBrand)), _majorBrand); 
    3838 
    39     if (!ReadUInt32(_minorVersion, false)) { 
    40         FATAL("Unable to read minor version"); 
    41         return false; 
    42     } 
    43     //FINEST("_minorVersion: %s(%u)", STR(U32TOS(_minorVersion)), _minorVersion); 
     39        if (!ReadUInt32(_minorVersion, false)) { 
     40                FATAL("Unable to read minor version"); 
     41                return false; 
     42        } 
     43        //FINEST("_minorVersion: %s(%u)", STR(U32TOS(_minorVersion)), _minorVersion); 
    4444 
    45     for (uint64_t i = 16; i < _size; i += 4) { 
    46         uint32_t val = 0; 
    47         if (!ReadUInt32(val, false)) { 
    48             FATAL("Unable to read compatible brand"); 
    49             return false; 
    50         } 
    51         ADD_VECTOR_END(_compatibleBrands, val); 
    52         //FINEST("_compatibleBrand: %s(%u)", STR(U32TOS(val)), val); 
    53     } 
    54     return true; 
     45        for (uint64_t i = 16; i < _size; i += 4) { 
     46                uint32_t val = 0; 
     47                if (!ReadUInt32(val, false)) { 
     48                        FATAL("Unable to read compatible brand"); 
     49                        return false; 
     50                } 
     51                ADD_VECTOR_END(_compatibleBrands, val); 
     52                //FINEST("_compatibleBrand: %s(%u)", STR(U32TOS(val)), val); 
     53        } 
     54        return true; 
    5555} 
    5656 
    5757string AtomFTYP::Hierarchy(uint32_t indent) { 
    58     return string(4 * indent, ' ') + GetTypeString(); 
     58        return string(4 * indent, ' ') + GetTypeString(); 
    5959} 
    6060 
    6161 
     62#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomhdlr.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomhdlr.h" 
    2222 
    2323AtomHDLR::AtomHDLR(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2424: VersionedAtom(pDocument, type, size, start) { 
    25     _componentType = 0; 
    26     _componentSubType = 0; 
    27     _componentManufacturer = 0; 
    28     _componentFlags = 0; 
    29     _componentFlagsMask = 0; 
    30     _componentName = ""; 
     25        _componentType = 0; 
     26        _componentSubType = 0; 
     27        _componentManufacturer = 0; 
     28        _componentFlags = 0; 
     29        _componentFlagsMask = 0; 
     30        _componentName = ""; 
    3131} 
    3232 
     
    3535 
    3636uint32_t AtomHDLR::GetComponentSubType() { 
    37     return _componentSubType; 
     37        return _componentSubType; 
    3838} 
    3939 
    4040bool AtomHDLR::ReadData() { 
    41     if (!ReadUInt32(_componentType)) { 
    42         FATAL("Unable to read component type"); 
    43         return false; 
    44     } 
    45     //FINEST("_componentType: %u", _componentType); 
     41        if (!ReadUInt32(_componentType)) { 
     42                FATAL("Unable to read component type"); 
     43                return false; 
     44        } 
     45        //FINEST("_componentType: %u", _componentType); 
    4646 
    47     if (!ReadUInt32(_componentSubType)) { 
    48         FATAL("Unable to read component sub type"); 
    49         return false; 
    50     } 
    51     //    FINEST("_componentSubType: %s(%u)", STR(U32TOS(_componentSubType)), 
    52     //            _componentSubType); 
     47        if (!ReadUInt32(_componentSubType)) { 
     48                FATAL("Unable to read component sub type"); 
     49                return false; 
     50        } 
     51        //    FINEST("_componentSubType: %s(%u)", STR(U32TOS(_componentSubType)), 
     52        //            _componentSubType); 
    5353 
    54     if (!ReadUInt32(_componentManufacturer)) { 
    55         FATAL("Unable to read component manufacturer"); 
    56         return false; 
    57     } 
    58     //FINEST("_componentManufacturer: %u", _componentManufacturer); 
     54        if (!ReadUInt32(_componentManufacturer)) { 
     55                FATAL("Unable to read component manufacturer"); 
     56                return false; 
     57        } 
     58        //FINEST("_componentManufacturer: %u", _componentManufacturer); 
    5959 
    60     if (!ReadUInt32(_componentFlags)) { 
    61         FATAL("Unable to read component flags"); 
    62         return false; 
    63     } 
    64     //FINEST("_componentFlags: %u", _componentFlags); 
     60        if (!ReadUInt32(_componentFlags)) { 
     61                FATAL("Unable to read component flags"); 
     62                return false; 
     63        } 
     64        //FINEST("_componentFlags: %u", _componentFlags); 
    6565 
    66     if (!ReadUInt32(_componentFlagsMask)) { 
    67         FATAL("Unable to read component flags mask"); 
    68         return false; 
    69     } 
    70     //FINEST("_componentFlagsMask: %u", _componentFlagsMask); 
     66        if (!ReadUInt32(_componentFlagsMask)) { 
     67                FATAL("Unable to read component flags mask"); 
     68                return false; 
     69        } 
     70        //FINEST("_componentFlagsMask: %u", _componentFlagsMask); 
    7171 
    72     if (!ReadString(_componentName, _size - 32)) { 
    73         FATAL("Unable to read component name"); 
    74         return false; 
    75     } 
    76     //FINEST("_componentFlagsMask: %s", STR(_componentName)); 
     72        if (!ReadString(_componentName, _size - 32)) { 
     73                FATAL("Unable to read component name"); 
     74                return false; 
     75        } 
     76        //FINEST("_componentFlagsMask: %s", STR(_componentName)); 
    7777 
    78     return true; 
     78        return true; 
    7979} 
    8080 
    8181string AtomHDLR::Hierarchy(uint32_t indent) { 
    82     return string(4 * indent, ' ') + GetTypeString() + "(" + U32TOS(_componentSubType) + ")"; 
     82        return string(4 * indent, ' ') + GetTypeString() + "(" + U32TOS(_componentSubType) + ")"; 
    8383} 
    8484 
    8585 
     86#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomilst.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomilst.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    3131 
    3232Variant AtomILST::GetVariant() { 
    33     Variant result; 
     33        Variant result; 
    3434 
    35     FOR_VECTOR(_metaFields, i) { 
    36         result[_metaFields[i]->GetTypeString()] = _metaFields[i]->GetVariant(); 
    37     } 
    38     return result; 
     35        FOR_VECTOR(_metaFields, i) { 
     36                result[_metaFields[i]->GetTypeString()] = _metaFields[i]->GetVariant(); 
     37        } 
     38        return result; 
    3939} 
    4040 
    4141bool AtomILST::AtomCreated(BaseAtom *pAtom) { 
    42     switch (pAtom->GetTypeNumeric()) { 
    43         case A__NAM: 
    44         case A_CPIL: 
    45         case A_PGAP: 
    46         case A_TMPO: 
    47         case A__TOO: 
    48         case A__ART: 
    49         case A__ALB: 
    50         case A_GNRE: 
    51         case A_TRKN: 
    52         case A__DAY: 
    53         case A_DISK: 
    54         case A__CMT: 
    55         case A_COVR: 
    56         case A_AART: 
    57         case A__WRT: 
    58         case A__GRP: 
    59         case A__LYR: 
    60         case A_DESC: 
    61         case A_TVSH: 
    62         case A_TVEN: 
    63         case A_TVSN: 
    64         case A_TVES: 
    65             ADD_VECTOR_END(_metaFields, (AtomMetaField *) pAtom); 
    66             return true; 
    67         default: 
    68         { 
    69             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    70             return false; 
    71         } 
    72     } 
     42        switch (pAtom->GetTypeNumeric()) { 
     43                case A__NAM: 
     44                case A_CPIL: 
     45                case A_PGAP: 
     46                case A_TMPO: 
     47                case A__TOO: 
     48                case A__ART: 
     49                case A__ALB: 
     50                case A_GNRE: 
     51                case A_TRKN: 
     52                case A__DAY: 
     53                case A_DISK: 
     54                case A__CMT: 
     55                case A_COVR: 
     56                case A_AART: 
     57                case A__WRT: 
     58                case A__GRP: 
     59                case A__LYR: 
     60                case A_DESC: 
     61                case A_TVSH: 
     62                case A_TVEN: 
     63                case A_TVSN: 
     64                case A_TVES: 
     65                        ADD_VECTOR_END(_metaFields, (AtomMetaField *) pAtom); 
     66                        return true; 
     67                default: 
     68                { 
     69                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     70                        return false; 
     71                } 
     72        } 
    7373} 
    7474 
     75#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atommdhd.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atommdhd.h" 
    2222 
    2323AtomMDHD::AtomMDHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2424: VersionedAtom(pDocument, type, size, start) { 
    25     _creationTime = 0; 
    26     _modificationTime = 0; 
    27     _timeScale = 0; 
    28     _duration = 0; 
    29     _language = 0; 
    30     _quality = 0; 
     25        _creationTime = 0; 
     26        _modificationTime = 0; 
     27        _timeScale = 0; 
     28        _duration = 0; 
     29        _language = 0; 
     30        _quality = 0; 
    3131} 
    3232 
     
    3535 
    3636uint32_t AtomMDHD::GetTimeScale() { 
    37     return _timeScale; 
     37        return _timeScale; 
    3838} 
    3939 
    4040uint32_t AtomMDHD::GetDuration() { 
    41     return _duration; 
     41        return _duration; 
    4242} 
    4343 
    4444bool AtomMDHD::ReadData() { 
    4545 
    46     if (!ReadUInt32(_creationTime)) { 
    47         FATAL("Unable to read creation time"); 
    48         return false; 
    49     } 
    50     //FINEST("_creationTime: %u", _creationTime); 
     46        if (!ReadUInt32(_creationTime)) { 
     47                FATAL("Unable to read creation time"); 
     48                return false; 
     49        } 
     50        //FINEST("_creationTime: %u", _creationTime); 
    5151 
    52     if (!ReadUInt32(_modificationTime)) { 
    53         FATAL("Unable to read modification time"); 
    54         return false; 
    55     } 
    56     //FINEST("_modificationTime: %u", _modificationTime); 
     52        if (!ReadUInt32(_modificationTime)) { 
     53                FATAL("Unable to read modification time"); 
     54                return false; 
     55        } 
     56        //FINEST("_modificationTime: %u", _modificationTime); 
    5757 
    58     if (!ReadUInt32(_timeScale)) { 
    59         FATAL("Unable to read time scale"); 
    60         return false; 
    61     } 
    62     //FINEST("_timeScale: %u", _timeScale); 
     58        if (!ReadUInt32(_timeScale)) { 
     59                FATAL("Unable to read time scale"); 
     60                return false; 
     61        } 
     62        //FINEST("_timeScale: %u", _timeScale); 
    6363 
    64     if (!ReadUInt32(_duration)) { 
    65         FATAL("Unable to read duration"); 
    66         return false; 
    67     } 
    68     //FINEST("_duration: %u", _duration); 
     64        if (!ReadUInt32(_duration)) { 
     65                FATAL("Unable to read duration"); 
     66                return false; 
     67        } 
     68        //FINEST("_duration: %u", _duration); 
    6969 
    70     if (!ReadUInt16(_language)) { 
    71         FATAL("Unable to read language"); 
    72         return false; 
    73     } 
    74     //FINEST("_language: %u", _language); 
     70        if (!ReadUInt16(_language)) { 
     71                FATAL("Unable to read language"); 
     72                return false; 
     73        } 
     74        //FINEST("_language: %u", _language); 
    7575 
    76     if (!ReadUInt16(_quality)) { 
    77         FATAL("Unable to read quality"); 
    78         return false; 
    79     } 
    80     //FINEST("_quality: %u", _quality); 
     76        if (!ReadUInt16(_quality)) { 
     77                FATAL("Unable to read quality"); 
     78                return false; 
     79        } 
     80        //FINEST("_quality: %u", _quality); 
    8181 
    82     return true; 
     82        return true; 
    8383} 
    8484 
    8585 
     86#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atommdia.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atommdia.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2424AtomMDIA::AtomMDIA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2525: BoxAtom(pDocument, type, size, start) { 
    26     _pMDHD = NULL; 
    27     _pHDLR = NULL; 
    28     _pMINF = NULL; 
    29     _pDINF = NULL; 
    30     _pSTBL = NULL; 
     26        _pMDHD = NULL; 
     27        _pHDLR = NULL; 
     28        _pMINF = NULL; 
     29        _pDINF = NULL; 
     30        _pSTBL = NULL; 
    3131} 
    3232 
     
    3535 
    3636bool AtomMDIA::AtomCreated(BaseAtom *pAtom) { 
    37     switch (pAtom->GetTypeNumeric()) { 
    38         case A_MDHD: 
    39             _pMDHD = (AtomMDHD *) pAtom; 
    40             return true; 
    41         case A_HDLR: 
    42             _pHDLR = (AtomHDLR *) pAtom; 
    43             return true; 
    44         case A_MINF: 
    45             _pMINF = (AtomMINF *) pAtom; 
    46             return true; 
    47         case A_DINF: 
    48             _pDINF = (AtomDINF *) pAtom; 
    49             return true; 
    50         case A_STBL: 
    51             _pSTBL = (AtomSTBL *) pAtom; 
    52             return true; 
    53         default: 
    54         { 
    55             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    56             return false; 
    57         } 
    58     } 
     37        switch (pAtom->GetTypeNumeric()) { 
     38                case A_MDHD: 
     39                        _pMDHD = (AtomMDHD *) pAtom; 
     40                        return true; 
     41                case A_HDLR: 
     42                        _pHDLR = (AtomHDLR *) pAtom; 
     43                        return true; 
     44                case A_MINF: 
     45                        _pMINF = (AtomMINF *) pAtom; 
     46                        return true; 
     47                case A_DINF: 
     48                        _pDINF = (AtomDINF *) pAtom; 
     49                        return true; 
     50                case A_STBL: 
     51                        _pSTBL = (AtomSTBL *) pAtom; 
     52                        return true; 
     53                default: 
     54                { 
     55                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     56                        return false; 
     57                } 
     58        } 
    5959} 
    6060 
    6161 
     62#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atommeta.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atommeta.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2424AtomMETA::AtomMETA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2525: VersionedBoxAtom(pDocument, type, size, start) { 
    26     _pHDLR = NULL; 
    27     _pILST = NULL; 
     26        _pHDLR = NULL; 
     27        _pILST = NULL; 
    2828} 
    2929 
     
    3232 
    3333bool AtomMETA::Read() { 
    34     if (_pParent == NULL) 
    35         return SkipRead(false); 
    36     if (_pParent->GetParentAtom() == NULL) 
    37         return SkipRead(false); 
    38     if (_pParent->GetTypeNumeric() != A_UDTA || 
    39             _pParent->GetParentAtom()->GetTypeNumeric() != A_MOOV) 
    40         return SkipRead(false); 
    41     return VersionedBoxAtom::Read(); 
     34        if (_pParent == NULL) 
     35                return SkipRead(false); 
     36        if (_pParent->GetParentAtom() == NULL) 
     37                return SkipRead(false); 
     38        if (_pParent->GetTypeNumeric() != A_UDTA || 
     39                        _pParent->GetParentAtom()->GetTypeNumeric() != A_MOOV) 
     40                return SkipRead(false); 
     41        return VersionedBoxAtom::Read(); 
    4242} 
    4343 
    4444bool AtomMETA::ReadData() { 
    45     return true; 
     45        return true; 
    4646} 
    4747 
    4848bool AtomMETA::AtomCreated(BaseAtom *pAtom) { 
    49     switch (pAtom->GetTypeNumeric()) { 
    50         case A_HDLR: 
    51             _pHDLR = (AtomHDLR *) pAtom; 
    52             return true; 
    53         case A_ILST: 
    54             _pILST = (AtomILST *) pAtom; 
    55             return true; 
    56         default: 
    57         { 
    58             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    59             return false; 
    60         } 
    61     } 
     49        switch (pAtom->GetTypeNumeric()) { 
     50                case A_HDLR: 
     51                        _pHDLR = (AtomHDLR *) pAtom; 
     52                        return true; 
     53                case A_ILST: 
     54                        _pILST = (AtomILST *) pAtom; 
     55                        return true; 
     56                default: 
     57                { 
     58                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     59                        return false; 
     60                } 
     61        } 
    6262} 
    6363 
     64#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atommetafield.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atommetafield.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2525AtomMetaField::AtomMetaField(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2626: BoxAtom(pDocument, type, size, start) { 
    27     _pDATA = NULL; 
     27        _pDATA = NULL; 
    2828} 
    2929 
     
    3232 
    3333bool AtomMetaField::Read() { 
    34     if (GetSize() >= 8) { 
    35         if (!GetDoc()->GetMediaFile().SeekAhead(4)) { 
    36             FATAL("Unable to seek 4 bytes"); 
    37             return false; 
    38         } 
    39         uint32_t type; 
    40         if (!ReadUInt32(type, false)) { 
    41             FATAL("Unable to read type"); 
    42             return false; 
    43         } 
    44         if (type != A_DATA) { 
    45             if (!GetDoc()->GetMediaFile().SeekBehind(4)) { 
    46                 FATAL("Unable to go back 4 bytes"); 
    47                 return false; 
    48             } 
    49             if (!ReadString(_stringData, GetSize() - 8 - 4)) { 
    50                 FATAL("Unable to read string"); 
    51                 return false; 
    52             } 
    53             return true; 
    54         } else { 
    55             if (!GetDoc()->GetMediaFile().SeekBehind(8)) { 
    56                 FATAL("Unable to go back 8 bytes"); 
    57                 return false; 
    58             } 
    59             return BoxAtom::Read(); 
    60         } 
    61     } else { 
    62         return BoxAtom::Read(); 
    63     } 
     34        if (GetSize() >= 8) { 
     35                if (!GetDoc()->GetMediaFile().SeekAhead(4)) { 
     36                        FATAL("Unable to seek 4 bytes"); 
     37                        return false; 
     38                } 
     39                uint32_t type; 
     40                if (!ReadUInt32(type, false)) { 
     41                        FATAL("Unable to read type"); 
     42                        return false; 
     43                } 
     44                if (type != A_DATA) { 
     45                        if (!GetDoc()->GetMediaFile().SeekBehind(4)) { 
     46                                FATAL("Unable to go back 4 bytes"); 
     47                                return false; 
     48                        } 
     49                        if (!ReadString(_stringData, GetSize() - 8 - 4)) { 
     50                                FATAL("Unable to read string"); 
     51                                return false; 
     52                        } 
     53                        return true; 
     54                } else { 
     55                        if (!GetDoc()->GetMediaFile().SeekBehind(8)) { 
     56                                FATAL("Unable to go back 8 bytes"); 
     57                                return false; 
     58                        } 
     59                        return BoxAtom::Read(); 
     60                } 
     61        } else { 
     62                return BoxAtom::Read(); 
     63        } 
    6464} 
    6565 
    6666bool AtomMetaField::AtomCreated(BaseAtom *pAtom) { 
    67     switch (pAtom->GetTypeNumeric()) { 
    68         case A_DATA: 
    69             _pDATA = (AtomDATA *) pAtom; 
    70             return true; 
    71         default: 
    72         { 
    73             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    74             return false; 
    75         } 
    76     } 
     67        switch (pAtom->GetTypeNumeric()) { 
     68                case A_DATA: 
     69                        _pDATA = (AtomDATA *) pAtom; 
     70                        return true; 
     71                default: 
     72                { 
     73                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     74                        return false; 
     75                } 
     76        } 
    7777} 
    7878 
    7979Variant AtomMetaField::GetVariant() { 
    80     if (_pDATA != NULL) 
    81         return _pDATA->GetVariant(); 
    82     return _stringData; 
     80        if (_pDATA != NULL) 
     81                return _pDATA->GetVariant(); 
     82        return _stringData; 
    8383} 
    8484 
     85#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomminf.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomminf.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2424AtomMINF::AtomMINF(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2525: BoxAtom(pDocument, type, size, start) { 
    26     _pSMHD = NULL; 
    27     _pDINF = NULL; 
    28     _pSTBL = NULL; 
    29     _pVMHD = NULL; 
    30     _pHDLR = NULL; 
     26        _pSMHD = NULL; 
     27        _pDINF = NULL; 
     28        _pSTBL = NULL; 
     29        _pVMHD = NULL; 
     30        _pHDLR = NULL; 
    3131} 
    3232 
     
    3535 
    3636bool AtomMINF::AtomCreated(BaseAtom *pAtom) { 
    37     switch (pAtom->GetTypeNumeric()) { 
    38         case A_SMHD: 
    39             _pSMHD = (AtomSMHD *) pAtom; 
    40             return true; 
    41         case A_DINF: 
    42             _pDINF = (AtomDINF *) pAtom; 
    43             return true; 
    44         case A_STBL: 
    45             _pSTBL = (AtomSTBL *) pAtom; 
    46             return true; 
    47         case A_VMHD: 
    48             _pVMHD = (AtomVMHD *) pAtom; 
    49             return true; 
    50         case A_HDLR: 
    51             _pHDLR = (AtomHDLR *) pAtom; 
    52             return true; 
    53         default: 
    54         { 
    55             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    56             return false; 
    57         } 
    58     } 
     37        switch (pAtom->GetTypeNumeric()) { 
     38                case A_SMHD: 
     39                        _pSMHD = (AtomSMHD *) pAtom; 
     40                        return true; 
     41                case A_DINF: 
     42                        _pDINF = (AtomDINF *) pAtom; 
     43                        return true; 
     44                case A_STBL: 
     45                        _pSTBL = (AtomSTBL *) pAtom; 
     46                        return true; 
     47                case A_VMHD: 
     48                        _pVMHD = (AtomVMHD *) pAtom; 
     49                        return true; 
     50                case A_HDLR: 
     51                        _pHDLR = (AtomHDLR *) pAtom; 
     52                        return true; 
     53                default: 
     54                { 
     55                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     56                        return false; 
     57                } 
     58        } 
    5959} 
    6060 
    6161 
     62#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atommoov.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atommoov.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2525AtomMOOV::AtomMOOV(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2626: BoxAtom(pDocument, type, size, start) { 
    27     _pMVHD = NULL; 
    28     _pUDTA = NULL; 
    29     _pMETA = NULL; 
     27        _pMVHD = NULL; 
     28        _pUDTA = NULL; 
     29        _pMETA = NULL; 
    3030} 
    3131 
     
    3434 
    3535vector<AtomTRAK *> AtomMOOV::GetTracks() { 
    36     return _tracks; 
     36        return _tracks; 
    3737} 
    3838 
    3939bool AtomMOOV::AtomCreated(BaseAtom *pAtom) { 
    40     switch (pAtom->GetTypeNumeric()) { 
    41         case A_MVHD: 
    42             _pMVHD = (AtomMVHD *) pAtom; 
    43             return true; 
    44         case A_UDTA: 
    45             _pUDTA = (AtomUDTA *) pAtom; 
    46             return true; 
    47         case A_TRAK: 
    48             ADD_VECTOR_END(_tracks, (AtomTRAK *) pAtom); 
    49             return true; 
    50         case A_META: 
    51             _pMETA = (AtomMETA *) pAtom; 
    52             return true; 
    53         default: 
    54         { 
    55             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    56             return false; 
    57         } 
    58     } 
     40        switch (pAtom->GetTypeNumeric()) { 
     41                case A_MVHD: 
     42                        _pMVHD = (AtomMVHD *) pAtom; 
     43                        return true; 
     44                case A_UDTA: 
     45                        _pUDTA = (AtomUDTA *) pAtom; 
     46                        return true; 
     47                case A_TRAK: 
     48                        ADD_VECTOR_END(_tracks, (AtomTRAK *) pAtom); 
     49                        return true; 
     50                case A_META: 
     51                        _pMETA = (AtomMETA *) pAtom; 
     52                        return true; 
     53                default: 
     54                { 
     55                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     56                        return false; 
     57                } 
     58        } 
    5959} 
    6060 
    6161 
     62#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atommp4a.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atommp4a.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2424AtomMP4A::AtomMP4A(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2525: VersionedBoxAtom(pDocument, type, size, start) { 
    26     _pESDS = NULL; 
    27     _pWAVE = NULL; 
    28     _pCHAN = NULL; 
    29     _dataReferenceIndex = 0; 
    30     _innerVersion = 0; 
    31     _revisionLevel = 0; 
    32     _vendor = 0; 
    33     _numberOfChannels = 0; 
    34     _sampleSizeInBits = 0; 
    35     _compressionId = 0; 
    36     _packetSize = 0; 
    37     _sampleRate = 0; 
    38     _samplesPerPacket = 0; 
    39     _bytesPerPacket = 0; 
    40     _bytesPerFrame = 0; 
    41     _bytesPerSample = 0; 
     26        _pESDS = NULL; 
     27        _pWAVE = NULL; 
     28        _pCHAN = NULL; 
     29        _dataReferenceIndex = 0; 
     30        _innerVersion = 0; 
     31        _revisionLevel = 0; 
     32        _vendor = 0; 
     33        _numberOfChannels = 0; 
     34        _sampleSizeInBits = 0; 
     35        _compressionId = 0; 
     36        _packetSize = 0; 
     37        _sampleRate = 0; 
     38        _samplesPerPacket = 0; 
     39        _bytesPerPacket = 0; 
     40        _bytesPerFrame = 0; 
     41        _bytesPerSample = 0; 
    4242} 
    4343 
     
    4646 
    4747bool AtomMP4A::ReadData() { 
    48     //qtff.pdf: General StructureofaSampleDescription (76/304) 
     48        //qtff.pdf: General StructureofaSampleDescription (76/304) 
    4949 
    50     //TODO: there seems to be 2 kinds of DISTINCT mp4a atoms. If the size 
    51     // of the atom is 0x0c (size+'mp4a'+4 zeros) we should ignore it for now... 
    52     if (_size == 0x0c) { 
    53         WARN("Another strange mp4a atom...."); 
    54         return true; 
    55     } 
     50        //TODO: there seems to be 2 kinds of DISTINCT mp4a atoms. If the size 
     51        // of the atom is 0x0c (size+'mp4a'+4 zeros) we should ignore it for now... 
     52        if (_size == 0x0c) { 
     53                WARN("Another strange mp4a atom...."); 
     54                return true; 
     55        } 
    5656 
    57     //1. Skip reserved 6 bytes. Actually, slip the next 2, because the prev 4 
    58     //are already skipped by the versioned atom 
    59     if (!SkipBytes(2)) { 
    60         FATAL("Unable to skip 2 bytes"); 
    61         return false; 
    62     } 
     57        //1. Skip reserved 6 bytes. Actually, slip the next 2, because the prev 4 
     58        //are already skipped by the versioned atom 
     59        if (!SkipBytes(2)) { 
     60                FATAL("Unable to skip 2 bytes"); 
     61                return false; 
     62        } 
    6363 
    64     if (!ReadUInt16(_dataReferenceIndex)) { 
    65         FATAL("Unable to read count"); 
    66         return false; 
    67     } 
    68     //FINEST("_dataReferenceIndex: %u", _dataReferenceIndex); 
     64        if (!ReadUInt16(_dataReferenceIndex)) { 
     65                FATAL("Unable to read count"); 
     66                return false; 
     67        } 
     68        //FINEST("_dataReferenceIndex: %u", _dataReferenceIndex); 
    6969 
    70     if (!ReadUInt16(_innerVersion)) { 
    71         FATAL("Unable to read count"); 
    72         return false; 
    73     } 
    74     //FINEST("_innerVersion: %u", _innerVersion); 
     70        if (!ReadUInt16(_innerVersion)) { 
     71                FATAL("Unable to read count"); 
     72                return false; 
     73        } 
     74        //FINEST("_innerVersion: %u", _innerVersion); 
    7575 
    76     if (!ReadUInt16(_revisionLevel)) { 
    77         FATAL("Unable to read count"); 
    78         return false; 
    79     } 
    80     //FINEST("_revisionLevel: %u", _revisionLevel); 
     76        if (!ReadUInt16(_revisionLevel)) { 
     77                FATAL("Unable to read count"); 
     78                return false; 
     79        } 
     80        //FINEST("_revisionLevel: %u", _revisionLevel); 
    8181 
    82     if (!ReadUInt32(_vendor)) { 
    83         FATAL("Unable to read count"); 
    84         return false; 
    85     } 
    86     //FINEST("_vendor: %u", _vendor); 
     82        if (!ReadUInt32(_vendor)) { 
     83                FATAL("Unable to read count"); 
     84                return false; 
     85        } 
     86        //FINEST("_vendor: %u", _vendor); 
    8787 
    88     if (!ReadUInt16(_numberOfChannels)) { 
    89         FATAL("Unable to read count"); 
    90         return false; 
    91     } 
    92     //FINEST("_numberOfChannels: %u", _numberOfChannels); 
     88        if (!ReadUInt16(_numberOfChannels)) { 
     89                FATAL("Unable to read count"); 
     90                return false; 
     91        } 
     92        //FINEST("_numberOfChannels: %u", _numberOfChannels); 
    9393 
    94     if (!ReadUInt16(_sampleSizeInBits)) { 
    95         FATAL("Unable to read count"); 
    96         return false; 
    97     } 
    98     //FINEST("_sampleSizeInBits: %u", _sampleSizeInBits); 
     94        if (!ReadUInt16(_sampleSizeInBits)) { 
     95                FATAL("Unable to read count"); 
     96                return false; 
     97        } 
     98        //FINEST("_sampleSizeInBits: %u", _sampleSizeInBits); 
    9999 
    100     if (!ReadInt16(_compressionId)) { 
    101         FATAL("Unable to read count"); 
    102         return false; 
    103     } 
    104     //FINEST("_compressionId: %d", _compressionId); 
     100        if (!ReadInt16(_compressionId)) { 
     101                FATAL("Unable to read count"); 
     102                return false; 
     103        } 
     104        //FINEST("_compressionId: %d", _compressionId); 
    105105 
    106     if (!ReadUInt16(_packetSize)) { 
    107         FATAL("Unable to read count"); 
    108         return false; 
    109     } 
    110     //FINEST("_packetSize: %u", _packetSize); 
     106        if (!ReadUInt16(_packetSize)) { 
     107                FATAL("Unable to read count"); 
     108                return false; 
     109        } 
     110        //FINEST("_packetSize: %u", _packetSize); 
    111111 
    112     if (!ReadUInt32(_sampleRate)) { 
    113         FATAL("Unable to read count"); 
    114         return false; 
    115     } 
    116     //FINEST("_sampleRate: 0x%08x", _sampleRate); 
     112        if (!ReadUInt32(_sampleRate)) { 
     113                FATAL("Unable to read count"); 
     114                return false; 
     115        } 
     116        //FINEST("_sampleRate: 0x%08x", _sampleRate); 
    117117 
    118     if (_innerVersion == 0) { 
    119         return true; 
    120     } 
     118        if (_innerVersion == 0) { 
     119                return true; 
     120        } 
    121121 
    122122 
    123     if (!ReadUInt32(_samplesPerPacket)) { 
    124         FATAL("Unable to read count"); 
    125         return false; 
    126     } 
    127     //FINEST("_samplesPerPacket: %u", _samplesPerPacket); 
     123        if (!ReadUInt32(_samplesPerPacket)) { 
     124                FATAL("Unable to read count"); 
     125                return false; 
     126        } 
     127        //FINEST("_samplesPerPacket: %u", _samplesPerPacket); 
    128128 
    129     if (!ReadUInt32(_bytesPerPacket)) { 
    130         FATAL("Unable to read count"); 
    131         return false; 
    132     } 
    133     //FINEST("_bytesPerPacket: %u", _bytesPerPacket); 
     129        if (!ReadUInt32(_bytesPerPacket)) { 
     130                FATAL("Unable to read count"); 
     131                return false; 
     132        } 
     133        //FINEST("_bytesPerPacket: %u", _bytesPerPacket); 
    134134 
    135     if (!ReadUInt32(_bytesPerFrame)) { 
    136         FATAL("Unable to read count"); 
    137         return false; 
    138     } 
    139     //FINEST("_bytesPerFrame: %u", _bytesPerFrame); 
     135        if (!ReadUInt32(_bytesPerFrame)) { 
     136                FATAL("Unable to read count"); 
     137                return false; 
     138        } 
     139        //FINEST("_bytesPerFrame: %u", _bytesPerFrame); 
    140140 
    141     if (!ReadUInt32(_bytesPerSample)) { 
    142         FATAL("Unable to read count"); 
    143         return false; 
    144     } 
    145     //FINEST("_bytesPerSample: %u", _bytesPerSample); 
     141        if (!ReadUInt32(_bytesPerSample)) { 
     142                FATAL("Unable to read count"); 
     143                return false; 
     144        } 
     145        //FINEST("_bytesPerSample: %u", _bytesPerSample); 
    146146 
    147     return true; 
     147        return true; 
    148148} 
    149149 
    150150bool AtomMP4A::AtomCreated(BaseAtom *pAtom) { 
    151     switch (pAtom->GetTypeNumeric()) { 
    152         case A_ESDS: 
    153             _pESDS = (AtomESDS *) pAtom; 
    154             return true; 
    155         case A_WAVE: 
    156             _pWAVE = (AtomWAVE *) pAtom; 
    157             return true; 
    158         case A_CHAN: 
    159             _pCHAN = (AtomCHAN *) pAtom; 
    160             return true; 
    161         default: 
    162         { 
    163             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    164             return false; 
    165         } 
    166     } 
     151        switch (pAtom->GetTypeNumeric()) { 
     152                case A_ESDS: 
     153                        _pESDS = (AtomESDS *) pAtom; 
     154                        return true; 
     155                case A_WAVE: 
     156                        _pWAVE = (AtomWAVE *) pAtom; 
     157                        return true; 
     158                case A_CHAN: 
     159                        _pCHAN = (AtomCHAN *) pAtom; 
     160                        return true; 
     161                default: 
     162                { 
     163                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     164                        return false; 
     165                } 
     166        } 
    167167} 
    168168 
     169#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atommvhd.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atommvhd.h" 
    2222 
    2323AtomMVHD::AtomMVHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2424: VersionedAtom(pDocument, type, size, start) { 
    25     _creationTime = 0; 
    26     _modificationTime = 0; 
    27     _timeScale = 0; 
    28     _duration = 0; 
    29     _preferredRate = 0; 
    30     _preferredVolume = 0; 
    31     memset(_reserved, 0, 10); 
    32     memset(_matrixStructure, 0, 36); 
    33     _previewTime = 0; 
    34     _previewDuration = 0; 
    35     _posterTime = 0; 
    36     _selectionTime = 0; 
    37     _selectionDuration = 0; 
    38     _currentTime = 0; 
    39     _nextTrakId = 0; 
     25        _creationTime = 0; 
     26        _modificationTime = 0; 
     27        _timeScale = 0; 
     28        _duration = 0; 
     29        _preferredRate = 0; 
     30        _preferredVolume = 0; 
     31        memset(_reserved, 0, 10); 
     32        memset(_matrixStructure, 0, 36); 
     33        _previewTime = 0; 
     34        _previewDuration = 0; 
     35        _posterTime = 0; 
     36        _selectionTime = 0; 
     37        _selectionDuration = 0; 
     38        _currentTime = 0; 
     39        _nextTrakId = 0; 
    4040} 
    4141 
     
    4444 
    4545bool AtomMVHD::ReadData() { 
    46     if (!ReadUInt32(_creationTime)) { 
    47         FATAL("Unable to read creation time"); 
    48         return false; 
    49     } 
    50     //FINEST("_creationTime: %u", _creationTime); 
     46        if (!ReadUInt32(_creationTime)) { 
     47                FATAL("Unable to read creation time"); 
     48                return false; 
     49        } 
     50        //FINEST("_creationTime: %u", _creationTime); 
    5151 
    52     if (!ReadUInt32(_modificationTime)) { 
    53         FATAL("Unable to read modification time"); 
    54         return false; 
    55     } 
    56     //FINEST("_modificationTime: %u", _modificationTime); 
     52        if (!ReadUInt32(_modificationTime)) { 
     53                FATAL("Unable to read modification time"); 
     54                return false; 
     55        } 
     56        //FINEST("_modificationTime: %u", _modificationTime); 
    5757 
    58     if (!ReadUInt32(_timeScale)) { 
    59         FATAL("Unable to read time scale"); 
    60         return false; 
    61     } 
    62     //FINEST("_timeScale: %u", _timeScale); 
     58        if (!ReadUInt32(_timeScale)) { 
     59                FATAL("Unable to read time scale"); 
     60                return false; 
     61        } 
     62        //FINEST("_timeScale: %u", _timeScale); 
    6363 
    64     if (!ReadUInt32(_duration)) { 
    65         FATAL("Unable to read duration"); 
    66         return false; 
    67     } 
    68     //FINEST("_duration: %u", _duration); 
     64        if (!ReadUInt32(_duration)) { 
     65                FATAL("Unable to read duration"); 
     66                return false; 
     67        } 
     68        //FINEST("_duration: %u", _duration); 
    6969 
    70     if (!ReadUInt32(_preferredRate)) { 
    71         FATAL("Unable to read preferred rate"); 
    72         return false; 
    73     } 
    74     //FINEST("_preferredRate: %u", _preferredRate); 
     70        if (!ReadUInt32(_preferredRate)) { 
     71                FATAL("Unable to read preferred rate"); 
     72                return false; 
     73        } 
     74        //FINEST("_preferredRate: %u", _preferredRate); 
    7575 
    76     if (!ReadUInt16(_preferredVolume)) { 
    77         FATAL("Unable to read preferred volume"); 
    78         return false; 
    79     } 
    80     //FINEST("_preferredVolume: %u", _preferredVolume); 
     76        if (!ReadUInt16(_preferredVolume)) { 
     77                FATAL("Unable to read preferred volume"); 
     78                return false; 
     79        } 
     80        //FINEST("_preferredVolume: %u", _preferredVolume); 
    8181 
    82     if (!ReadArray(_reserved, 10)) { 
    83         FATAL("Unable to read reserved"); 
    84         return false; 
    85     } 
    86     //    FINEST("_reserved: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", 
    87     //            _reserved[0], _reserved[1], _reserved[2], _reserved[3], 
    88     //    _reserved[4], _reserved[5], _reserved[6], _reserved[7], 
    89     //            _reserved[8], _reserved[9]); 
     82        if (!ReadArray(_reserved, 10)) { 
     83                FATAL("Unable to read reserved"); 
     84                return false; 
     85        } 
     86        //    FINEST("_reserved: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", 
     87        //            _reserved[0], _reserved[1], _reserved[2], _reserved[3], 
     88        //    _reserved[4], _reserved[5], _reserved[6], _reserved[7], 
     89        //            _reserved[8], _reserved[9]); 
    9090 
    91     if (!ReadArray((uint8_t *) _matrixStructure, 36)) { 
    92         FATAL("Unable to read matrix structure"); 
    93         return false; 
    94     } 
     91        if (!ReadArray((uint8_t *) _matrixStructure, 36)) { 
     92                FATAL("Unable to read matrix structure"); 
     93                return false; 
     94        } 
    9595 
    96     if (!ReadUInt32(_previewTime)) { 
    97         FATAL("Unable to read preview time"); 
    98         return false; 
    99     } 
    100     //FINEST("_previewTime: %u", _previewTime); 
     96        if (!ReadUInt32(_previewTime)) { 
     97                FATAL("Unable to read preview time"); 
     98                return false; 
     99        } 
     100        //FINEST("_previewTime: %u", _previewTime); 
    101101 
    102     if (!ReadUInt32(_previewDuration)) { 
    103         FATAL("Unable to read preview duration"); 
    104         return false; 
    105     } 
    106     //FINEST("_previewDuration: %u", _previewDuration); 
     102        if (!ReadUInt32(_previewDuration)) { 
     103                FATAL("Unable to read preview duration"); 
     104                return false; 
     105        } 
     106        //FINEST("_previewDuration: %u", _previewDuration); 
    107107 
    108     if (!ReadUInt32(_posterTime)) { 
    109         FATAL("Unable to read poster time"); 
    110         return false; 
    111     } 
    112     //FINEST("_posterTime: %u", _posterTime); 
     108        if (!ReadUInt32(_posterTime)) { 
     109                FATAL("Unable to read poster time"); 
     110                return false; 
     111        } 
     112        //FINEST("_posterTime: %u", _posterTime); 
    113113 
    114     if (!ReadUInt32(_selectionTime)) { 
    115         FATAL("Unable to read selection time"); 
    116         return false; 
    117     } 
    118     //FINEST("_selectionTime: %u", _selectionTime); 
     114        if (!ReadUInt32(_selectionTime)) { 
     115                FATAL("Unable to read selection time"); 
     116                return false; 
     117        } 
     118        //FINEST("_selectionTime: %u", _selectionTime); 
    119119 
    120     if (!ReadUInt32(_selectionDuration)) { 
    121         FATAL("Unable to read selection duration"); 
    122         return false; 
    123     } 
    124     //FINEST("_selectionDuration: %u", _selectionDuration); 
     120        if (!ReadUInt32(_selectionDuration)) { 
     121                FATAL("Unable to read selection duration"); 
     122                return false; 
     123        } 
     124        //FINEST("_selectionDuration: %u", _selectionDuration); 
    125125 
    126     if (!ReadUInt32(_currentTime)) { 
    127         FATAL("Unable to read current time"); 
    128         return false; 
    129     } 
    130     //FINEST("_currentTime: %u", _currentTime); 
     126        if (!ReadUInt32(_currentTime)) { 
     127                FATAL("Unable to read current time"); 
     128                return false; 
     129        } 
     130        //FINEST("_currentTime: %u", _currentTime); 
    131131 
    132     if (!ReadUInt32(_nextTrakId)) { 
    133         FATAL("Unable to read next track ID"); 
    134         return false; 
    135     } 
    136     //FINEST("_nextTrakId: %u", _nextTrakId); 
     132        if (!ReadUInt32(_nextTrakId)) { 
     133                FATAL("Unable to read next track ID"); 
     134                return false; 
     135        } 
     136        //FINEST("_nextTrakId: %u", _nextTrakId); 
    137137 
    138     return true; 
     138        return true; 
    139139} 
    140140 
    141141 
     142#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomnull.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomnull.h" 
    2222 
     
    3030 
    3131bool AtomNULL::IsIgnored() { 
    32     return true; 
     32        return true; 
    3333} 
    3434 
    3535bool AtomNULL::Read() { 
    36     return SkipRead(false); 
     36        return SkipRead(false); 
    3737} 
    3838 
    3939string AtomNULL::Hierarchy(uint32_t indent) { 
    40     return string(4 * indent, ' ') + "null"; 
     40        return string(4 * indent, ' ') + "null"; 
    4141} 
    4242 
    4343 
     44#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomsmhd.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomsmhd.h" 
    2222 
    2323AtomSMHD::AtomSMHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2424: VersionedAtom(pDocument, type, size, start) { 
    25     _balance = 0; 
    26     _reserved = 0; 
     25        _balance = 0; 
     26        _reserved = 0; 
    2727} 
    2828 
     
    3131 
    3232bool AtomSMHD::ReadData() { 
    33     if (!ReadUInt16(_balance)) { 
    34         FATAL("Unable to read balance"); 
    35         return false; 
    36     } 
    37     //FINEST("_balance: %u", _balance); 
     33        if (!ReadUInt16(_balance)) { 
     34                FATAL("Unable to read balance"); 
     35                return false; 
     36        } 
     37        //FINEST("_balance: %u", _balance); 
    3838 
    39     if (!ReadUInt16(_reserved)) { 
    40         FATAL("Unable to read reserved"); 
    41         return false; 
    42     } 
    43     //FINEST("_reserved: %u", _reserved); 
     39        if (!ReadUInt16(_reserved)) { 
     40                FATAL("Unable to read reserved"); 
     41                return false; 
     42        } 
     43        //FINEST("_reserved: %u", _reserved); 
    4444 
    45     return true; 
     45        return true; 
    4646} 
    4747 
    4848 
     49#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomstbl.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomstbl.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2424AtomSTBL::AtomSTBL(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2525: BoxAtom(pDocument, type, size, start) { 
    26     _pSTSD = NULL; 
    27     _pSTTS = NULL; 
    28     _pSTSC = NULL; 
    29     _pSTSZ = NULL; 
    30     _pSTCO = NULL; 
    31     _pCTTS = NULL; 
    32     _pSTSS = NULL; 
     26        _pSTSD = NULL; 
     27        _pSTTS = NULL; 
     28        _pSTSC = NULL; 
     29        _pSTSZ = NULL; 
     30        _pSTCO = NULL; 
     31        _pCTTS = NULL; 
     32        _pSTSS = NULL; 
    3333} 
    3434 
     
    3737 
    3838bool AtomSTBL::AtomCreated(BaseAtom *pAtom) { 
    39     switch (pAtom->GetTypeNumeric()) { 
    40         case A_STSD: 
    41             _pSTSD = (AtomSTSD *) pAtom; 
    42             return true; 
    43         case A_STTS: 
    44             _pSTTS = (AtomSTTS *) pAtom; 
    45             return true; 
    46         case A_STSC: 
    47             _pSTSC = (AtomSTSC *) pAtom; 
    48             return true; 
    49         case A_STSZ: 
    50             _pSTSZ = (AtomSTSZ *) pAtom; 
    51             return true; 
    52         case A_STCO: 
    53             _pSTCO = (AtomSTCO *) pAtom; 
    54             return true; 
    55         case A_CO64: 
    56             _pCO64 = (AtomCO64 *) pAtom; 
    57             return true; 
    58         case A_CTTS: 
    59             _pCTTS = (AtomCTTS *) pAtom; 
    60             return true; 
    61         case A_STSS: 
    62             _pSTSS = (AtomSTSS *) pAtom; 
    63             return true; 
    64         default: 
    65         { 
    66             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    67             return false; 
    68         } 
    69     } 
     39        switch (pAtom->GetTypeNumeric()) { 
     40                case A_STSD: 
     41                        _pSTSD = (AtomSTSD *) pAtom; 
     42                        return true; 
     43                case A_STTS: 
     44                        _pSTTS = (AtomSTTS *) pAtom; 
     45                        return true; 
     46                case A_STSC: 
     47                        _pSTSC = (AtomSTSC *) pAtom; 
     48                        return true; 
     49                case A_STSZ: 
     50                        _pSTSZ = (AtomSTSZ *) pAtom; 
     51                        return true; 
     52                case A_STCO: 
     53                        _pSTCO = (AtomSTCO *) pAtom; 
     54                        return true; 
     55                case A_CO64: 
     56                        _pCO64 = (AtomCO64 *) pAtom; 
     57                        return true; 
     58                case A_CTTS: 
     59                        _pCTTS = (AtomCTTS *) pAtom; 
     60                        return true; 
     61                case A_STSS: 
     62                        _pSTSS = (AtomSTSS *) pAtom; 
     63                        return true; 
     64                default: 
     65                { 
     66                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     67                        return false; 
     68                } 
     69        } 
    7070} 
    7171 
     72#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomstco.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomstco.h" 
    2222 
     
    3030 
    3131vector<uint64_t> AtomSTCO::GetEntries() { 
    32     return _entries; 
     32        return _entries; 
    3333} 
    3434 
    3535bool AtomSTCO::ReadData() { 
    36     uint32_t count; 
     36        uint32_t count; 
    3737 
    38     if (!ReadUInt32(count)) { 
    39         FATAL("Unable to read count"); 
    40         return false; 
    41     } 
    42     //FINEST("count: %u", count); 
     38        if (!ReadUInt32(count)) { 
     39                FATAL("Unable to read count"); 
     40                return false; 
     41        } 
     42        //FINEST("count: %u", count); 
    4343 
    44     for (uint32_t i = 0; i < count; i++) { 
    45         uint32_t offset; 
    46         if (!ReadUInt32(offset)) { 
    47             FATAL("Unable to read offset"); 
    48             return false; 
    49         } 
    50         //FINEST("offset[%u]: %u", i, offset); 
    51         ADD_VECTOR_END(_entries, offset); 
    52     } 
    53     return true; 
     44        for (uint32_t i = 0; i < count; i++) { 
     45                uint32_t offset; 
     46                if (!ReadUInt32(offset)) { 
     47                        FATAL("Unable to read offset"); 
     48                        return false; 
     49                } 
     50                //FINEST("offset[%u]: %u", i, offset); 
     51                ADD_VECTOR_END(_entries, offset); 
     52        } 
     53        return true; 
    5454} 
    5555 
     56#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomstsc.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomstsc.h" 
    2222 
     
    2929 
    3030vector<uint32_t> AtomSTSC::GetEntries(uint32_t totalChunksCount) { 
    31     if (_normalizedEntries.size() != 0) 
    32         return _normalizedEntries; 
     31        if (_normalizedEntries.size() != 0) 
     32                return _normalizedEntries; 
    3333 
    34     //1. Expand the table 
    35     vector<uint32_t> samplesPerChunk; 
    36     for (uint32_t i = 0; i < _stscEntries.size() - 1; i++) { 
    37         for (uint32_t j = 0; j < _stscEntries[i + 1].firstChunk - _stscEntries[i].firstChunk; j++) { 
    38             ADD_VECTOR_END(samplesPerChunk, _stscEntries[i].samplesPerChunk); 
    39         } 
    40     } 
     34        //1. Expand the table 
     35        vector<uint32_t> samplesPerChunk; 
     36        for (uint32_t i = 0; i < _stscEntries.size() - 1; i++) { 
     37                for (uint32_t j = 0; j < _stscEntries[i + 1].firstChunk - _stscEntries[i].firstChunk; j++) { 
     38                        ADD_VECTOR_END(samplesPerChunk, _stscEntries[i].samplesPerChunk); 
     39                } 
     40        } 
    4141 
    42     uint32_t samplesPerChunkCount = samplesPerChunk.size(); 
    43     for (uint32_t i = 0; i < totalChunksCount - samplesPerChunkCount; i++) { 
    44         ADD_VECTOR_END(samplesPerChunk, 
    45                 _stscEntries[_stscEntries.size() - 1].samplesPerChunk); 
    46     } 
     42        uint32_t samplesPerChunkCount = samplesPerChunk.size(); 
     43        for (uint32_t i = 0; i < totalChunksCount - samplesPerChunkCount; i++) { 
     44                ADD_VECTOR_END(samplesPerChunk, 
     45                                _stscEntries[_stscEntries.size() - 1].samplesPerChunk); 
     46        } 
    4747 
    48     //2. build the final result based on the expanded table 
    49     samplesPerChunkCount = samplesPerChunk.size(); 
    50     for (uint32_t i = 0; i < samplesPerChunkCount; i++) { 
    51         for (uint32_t j = 0; j < samplesPerChunk[i]; j++) { 
    52             ADD_VECTOR_END(_normalizedEntries, i); 
    53         } 
    54     } 
     48        //2. build the final result based on the expanded table 
     49        samplesPerChunkCount = samplesPerChunk.size(); 
     50        for (uint32_t i = 0; i < samplesPerChunkCount; i++) { 
     51                for (uint32_t j = 0; j < samplesPerChunk[i]; j++) { 
     52                        ADD_VECTOR_END(_normalizedEntries, i); 
     53                } 
     54        } 
    5555 
    56     return _normalizedEntries; 
     56        return _normalizedEntries; 
    5757} 
    5858 
    5959bool AtomSTSC::ReadData() { 
    60     uint32_t count; 
    61     if (!ReadUInt32(count)) { 
    62         FATAL("Unable to read count"); 
    63         return false; 
    64     } 
    65     //FINEST("count: %u", count); 
     60        uint32_t count; 
     61        if (!ReadUInt32(count)) { 
     62                FATAL("Unable to read count"); 
     63                return false; 
     64        } 
     65        //FINEST("count: %u", count); 
    6666 
    67     if (count == 0) 
    68         return true; 
     67        if (count == 0) 
     68                return true; 
    6969 
    70     for (uint32_t i = 0; i < count; i++) { 
    71         STSCEntry entry; 
     70        for (uint32_t i = 0; i < count; i++) { 
     71                STSCEntry entry; 
    7272 
    73         if (!ReadUInt32(entry.firstChunk)) { 
    74             FATAL("Unable to read first chunk"); 
    75             return false; 
    76         } 
    77         //FINEST("entry.firstChunk: %u", entry.firstChunk); 
     73                if (!ReadUInt32(entry.firstChunk)) { 
     74                        FATAL("Unable to read first chunk"); 
     75                        return false; 
     76                } 
     77                //FINEST("entry.firstChunk: %u", entry.firstChunk); 
    7878 
    79         if (!ReadUInt32(entry.samplesPerChunk)) { 
    80             FATAL("Unable to read first samples per chunk"); 
    81             return false; 
    82         } 
    83         //FINEST("entry.samplesPerChunk: %u", entry.samplesPerChunk); 
     79                if (!ReadUInt32(entry.samplesPerChunk)) { 
     80                        FATAL("Unable to read first samples per chunk"); 
     81                        return false; 
     82                } 
     83                //FINEST("entry.samplesPerChunk: %u", entry.samplesPerChunk); 
    8484 
    85         if (!ReadUInt32(entry.sampleDescriptionIndex)) { 
    86             FATAL("Unable to read first sample description index"); 
    87             return false; 
    88         } 
    89         //FINEST("entry.sampleDescriptionIndex: %u", entry.sampleDescriptionIndex); 
     85                if (!ReadUInt32(entry.sampleDescriptionIndex)) { 
     86                        FATAL("Unable to read first sample description index"); 
     87                        return false; 
     88                } 
     89                //FINEST("entry.sampleDescriptionIndex: %u", entry.sampleDescriptionIndex); 
    9090 
    91         ADD_VECTOR_END(_stscEntries, entry); 
    92     } 
     91                ADD_VECTOR_END(_stscEntries, entry); 
     92        } 
    9393 
    94     return true; 
     94        return true; 
    9595} 
    9696 
    9797 
     98#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomstsd.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomstsd.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2424AtomSTSD::AtomSTSD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2525: VersionedBoxAtom(pDocument, type, size, start) { 
    26     _pAVC1 = NULL; 
    27     _pMP4A = NULL; 
     26        _pAVC1 = NULL; 
     27        _pMP4A = NULL; 
    2828} 
    2929 
     
    3232 
    3333bool AtomSTSD::ReadData() { 
    34     uint32_t count; 
    35     if (!ReadUInt32(count)) { 
    36         FATAL("Unable to read count"); 
    37         return false; 
    38     } 
    39     return true; 
     34        uint32_t count; 
     35        if (!ReadUInt32(count)) { 
     36                FATAL("Unable to read count"); 
     37                return false; 
     38        } 
     39        return true; 
    4040} 
    4141 
    4242bool AtomSTSD::AtomCreated(BaseAtom *pAtom) { 
    43     switch (pAtom->GetTypeNumeric()) { 
    44         case A_MP4A: 
    45             _pMP4A = (AtomMP4A *) pAtom; 
    46             return true; 
    47         case A_AVC1: 
    48             _pAVC1 = (AtomAVC1 *) pAtom; 
    49             return true; 
    50         default: 
    51         { 
    52             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    53             return false; 
    54         } 
    55     } 
     43        switch (pAtom->GetTypeNumeric()) { 
     44                case A_MP4A: 
     45                        _pMP4A = (AtomMP4A *) pAtom; 
     46                        return true; 
     47                case A_AVC1: 
     48                        _pAVC1 = (AtomAVC1 *) pAtom; 
     49                        return true; 
     50                default: 
     51                { 
     52                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     53                        return false; 
     54                } 
     55        } 
    5656} 
    5757 
     58#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomstss.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomstss.h" 
    2222 
     
    3030 
    3131vector<uint32_t> AtomSTSS::GetEntries() { 
    32     return _entries; 
     32        return _entries; 
    3333} 
    3434 
    3535bool AtomSTSS::ReadData() { 
    36     uint32_t count; 
    37     if (!ReadUInt32(count)) { 
    38         FATAL("Unable to read count"); 
    39         return false; 
    40     } 
    41     //FINEST("count: %u", count); 
     36        uint32_t count; 
     37        if (!ReadUInt32(count)) { 
     38                FATAL("Unable to read count"); 
     39                return false; 
     40        } 
     41        //FINEST("count: %u", count); 
    4242 
    43     for (uint32_t i = 0; i < count; i++) { 
    44         uint32_t sampleNumber; 
    45         if (!ReadUInt32(sampleNumber)) { 
    46             FATAL("Unable to read sample number"); 
    47             return false; 
    48         } 
    49         //FINEST("sampleNumber[%u]: %u", i, sampleNumber); 
     43        for (uint32_t i = 0; i < count; i++) { 
     44                uint32_t sampleNumber; 
     45                if (!ReadUInt32(sampleNumber)) { 
     46                        FATAL("Unable to read sample number"); 
     47                        return false; 
     48                } 
     49                //FINEST("sampleNumber[%u]: %u", i, sampleNumber); 
    5050 
    51         ADD_VECTOR_END(_entries, sampleNumber); 
    52     } 
    53     return true; 
     51                ADD_VECTOR_END(_entries, sampleNumber); 
     52        } 
     53        return true; 
    5454} 
    5555 
     56#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomstsz.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomstsz.h" 
    2222 
     
    3030 
    3131vector<uint64_t> AtomSTSZ::GetEntries() { 
    32     return _entries; 
     32        return _entries; 
    3333} 
    3434 
    3535bool AtomSTSZ::ReadData() { 
    36     if (!ReadUInt32(_sampleSize)) { 
    37         FATAL("Unable to read sample size"); 
    38         return false; 
    39     } 
    40     //FINEST("_sampleSize: %u", _sampleSize); 
     36        if (!ReadUInt32(_sampleSize)) { 
     37                FATAL("Unable to read sample size"); 
     38                return false; 
     39        } 
     40        //FINEST("_sampleSize: %u", _sampleSize); 
    4141 
    42     if (!ReadUInt32(_sampleCount)) { 
    43         FATAL("Unable to read sample count"); 
    44         return false; 
    45     } 
    46     //FINEST("_sampleCount: %u", _sampleCount); 
     42        if (!ReadUInt32(_sampleCount)) { 
     43                FATAL("Unable to read sample count"); 
     44                return false; 
     45        } 
     46        //FINEST("_sampleCount: %u", _sampleCount); 
    4747 
    48     if (_sampleSize != 0) { 
    49         for (uint32_t i = 0; i < _sampleCount; i++) { 
    50             ADD_VECTOR_END(_entries, _sampleSize); 
    51         } 
    52         return true; 
    53     } else { 
    54         for (uint32_t i = 0; i < _sampleCount; i++) { 
    55             uint32_t size; 
    56             if (!ReadUInt32(size)) { 
    57                 FATAL("Unable to read size"); 
    58                 return false; 
    59             } 
    60             //FINEST("size[%u]: %u", i, size); 
    61             ADD_VECTOR_END(_entries, size); 
    62         } 
    63         return true; 
    64     } 
     48        if (_sampleSize != 0) { 
     49                for (uint32_t i = 0; i < _sampleCount; i++) { 
     50                        ADD_VECTOR_END(_entries, _sampleSize); 
     51                } 
     52                return true; 
     53        } else { 
     54                for (uint32_t i = 0; i < _sampleCount; i++) { 
     55                        uint32_t size; 
     56                        if (!ReadUInt32(size)) { 
     57                                FATAL("Unable to read size"); 
     58                                return false; 
     59                        } 
     60                        //FINEST("size[%u]: %u", i, size); 
     61                        ADD_VECTOR_END(_entries, size); 
     62                } 
     63                return true; 
     64        } 
    6565} 
    6666 
     67#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomstts.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomstts.h" 
    2222#include "utils/core.h" 
     
    3030 
    3131vector<uint32_t> AtomSTTS::GetEntries() { 
    32     if (_normalizedEntries.size() != 0) 
    33         return _normalizedEntries; 
     32        if (_normalizedEntries.size() != 0) 
     33                return _normalizedEntries; 
    3434 
    35     FOR_VECTOR_ITERATOR(STTSEntry, _sttsEntries, i) { 
    36         for (uint32_t j = 0; j < VECTOR_VAL(i).count; j++) { 
    37             ADD_VECTOR_END(_normalizedEntries, VECTOR_VAL(i).delta); 
    38         } 
    39     } 
    40     return _normalizedEntries; 
     35        FOR_VECTOR_ITERATOR(STTSEntry, _sttsEntries, i) { 
     36                for (uint32_t j = 0; j < VECTOR_VAL(i).count; j++) { 
     37                        ADD_VECTOR_END(_normalizedEntries, VECTOR_VAL(i).delta); 
     38                } 
     39        } 
     40        return _normalizedEntries; 
    4141} 
    4242 
    4343bool AtomSTTS::ReadData() { 
    44     uint32_t entryCount; 
    45     if (!ReadUInt32(entryCount)) { 
    46         FATAL("Unable to read entry count"); 
    47         return false; 
    48     } 
    49     //FINEST("entryCount: %d", entryCount); 
     44        uint32_t entryCount; 
     45        if (!ReadUInt32(entryCount)) { 
     46                FATAL("Unable to read entry count"); 
     47                return false; 
     48        } 
     49        //FINEST("entryCount: %d", entryCount); 
    5050 
    51     for (uint32_t i = 0; i < entryCount; i++) { 
    52         STTSEntry entry; 
     51        for (uint32_t i = 0; i < entryCount; i++) { 
     52                STTSEntry entry; 
    5353 
    54         if (!ReadUInt32(entry.count)) { 
    55             FATAL("Unable to read count"); 
    56             return false; 
    57         } 
    58         //FINEST("entry[%d].count: %d", i, entry.count); 
     54                if (!ReadUInt32(entry.count)) { 
     55                        FATAL("Unable to read count"); 
     56                        return false; 
     57                } 
     58                //FINEST("entry[%d].count: %d", i, entry.count); 
    5959 
    60         if (!ReadUInt32(entry.delta)) { 
    61             FATAL("Unable to read delta"); 
    62             return false; 
    63         } 
    64         //FINEST("entry[%d].delta: %d", i, entry.delta); 
     60                if (!ReadUInt32(entry.delta)) { 
     61                        FATAL("Unable to read delta"); 
     62                        return false; 
     63                } 
     64                //FINEST("entry[%d].delta: %d", i, entry.delta); 
    6565 
    66         ADD_VECTOR_END(_sttsEntries, entry); 
    67     } 
    68     return true; 
     66                ADD_VECTOR_END(_sttsEntries, entry); 
     67        } 
     68        return true; 
    6969} 
    7070 
    7171 
     72#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomtkhd.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomtkhd.h" 
    2222 
    2323AtomTKHD::AtomTKHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2424: VersionedAtom(pDocument, type, size, start) { 
    25     _creationTime = 0; 
    26     _modificationTime = 0; 
    27     _trackId = 0; 
    28     memset(_reserved1, 0, 4); 
    29     _duration = 0; 
    30     memset(_reserved2, 0, 8); 
    31     _layer = 0; 
    32     _alternateGroup = 0; 
    33     _volume = 0; 
    34     memset(_reserved3, 0, 2); 
    35     memset(_matrixStructure, 0, 36); 
    36     _trackWidth = 0; 
    37     _trackHeight = 0; 
     25        _creationTime = 0; 
     26        _modificationTime = 0; 
     27        _trackId = 0; 
     28        memset(_reserved1, 0, 4); 
     29        _duration = 0; 
     30        memset(_reserved2, 0, 8); 
     31        _layer = 0; 
     32        _alternateGroup = 0; 
     33        _volume = 0; 
     34        memset(_reserved3, 0, 2); 
     35        memset(_matrixStructure, 0, 36); 
     36        _trackWidth = 0; 
     37        _trackHeight = 0; 
    3838} 
    3939 
     
    4242 
    4343uint32_t AtomTKHD::GetWidth() { 
    44     return _trackWidth >> 16; 
     44        return _trackWidth >> 16; 
    4545} 
    4646 
    4747uint32_t AtomTKHD::GetHeight() { 
    48     return _trackHeight >> 16; 
     48        return _trackHeight >> 16; 
    4949} 
    5050 
    5151bool AtomTKHD::ReadData() { 
    52     if (!ReadUInt32(_creationTime)) { 
    53         FATAL("Unable to read creation time"); 
    54         return false; 
    55     } 
    56     //FINEST("_creationTime: %u", _creationTime); 
     52        if (!ReadUInt32(_creationTime)) { 
     53                FATAL("Unable to read creation time"); 
     54                return false; 
     55        } 
     56        //FINEST("_creationTime: %u", _creationTime); 
    5757 
    58     if (!ReadUInt32(_modificationTime)) { 
    59         FATAL("Unable to read modification time"); 
    60         return false; 
    61     } 
    62     //FINEST("_modificationTime: %u", _modificationTime); 
     58        if (!ReadUInt32(_modificationTime)) { 
     59                FATAL("Unable to read modification time"); 
     60                return false; 
     61        } 
     62        //FINEST("_modificationTime: %u", _modificationTime); 
    6363 
    64     if (!ReadUInt32(_trackId)) { 
    65         FATAL("Unable to read track id"); 
    66         return false; 
    67     } 
    68     //FINEST("_trackId: %u", _trackId); 
     64        if (!ReadUInt32(_trackId)) { 
     65                FATAL("Unable to read track id"); 
     66                return false; 
     67        } 
     68        //FINEST("_trackId: %u", _trackId); 
    6969 
    70     if (!ReadArray(_reserved1, 4)) { 
    71         FATAL("Unable to read reserved 1"); 
    72         return false; 
    73     } 
     70        if (!ReadArray(_reserved1, 4)) { 
     71                FATAL("Unable to read reserved 1"); 
     72                return false; 
     73        } 
    7474 
    75     if (!ReadUInt32(_duration)) { 
    76         FATAL("Unable to read duration"); 
    77         return false; 
    78     } 
    79     //FINEST("_duration: %u", _duration); 
     75        if (!ReadUInt32(_duration)) { 
     76                FATAL("Unable to read duration"); 
     77                return false; 
     78        } 
     79        //FINEST("_duration: %u", _duration); 
    8080 
    81     if (!ReadArray(_reserved2, 8)) { 
    82         FATAL("Unable to read reserved 2"); 
    83         return false; 
    84     } 
     81        if (!ReadArray(_reserved2, 8)) { 
     82                FATAL("Unable to read reserved 2"); 
     83                return false; 
     84        } 
    8585 
    86     if (!ReadUInt16(_layer)) { 
    87         FATAL("Unable to read layer"); 
    88         return false; 
    89     } 
    90     //FINEST("_layer: %u", _layer); 
     86        if (!ReadUInt16(_layer)) { 
     87                FATAL("Unable to read layer"); 
     88                return false; 
     89        } 
     90        //FINEST("_layer: %u", _layer); 
    9191 
    92     if (!ReadUInt16(_alternateGroup)) { 
    93         FATAL("Unable to read alternate group"); 
    94         return false; 
    95     } 
    96     //FINEST("_alternateGroup: %u", _alternateGroup); 
     92        if (!ReadUInt16(_alternateGroup)) { 
     93                FATAL("Unable to read alternate group"); 
     94                return false; 
     95        } 
     96        //FINEST("_alternateGroup: %u", _alternateGroup); 
    9797 
    98     if (!ReadUInt16(_volume)) { 
    99         FATAL("Unable to read volume"); 
    100         return false; 
    101     } 
    102     //FINEST("_volume: %u", _volume); 
     98        if (!ReadUInt16(_volume)) { 
     99                FATAL("Unable to read volume"); 
     100                return false; 
     101        } 
     102        //FINEST("_volume: %u", _volume); 
    103103 
    104     if (!ReadArray(_reserved3, 2)) { 
    105         FATAL("Unable to read reserved 3"); 
    106         return false; 
    107     } 
     104        if (!ReadArray(_reserved3, 2)) { 
     105                FATAL("Unable to read reserved 3"); 
     106                return false; 
     107        } 
    108108 
    109     if (!ReadArray(_matrixStructure, 36)) { 
    110         FATAL("Unable to read matrix structure"); 
    111         return false; 
    112     } 
     109        if (!ReadArray(_matrixStructure, 36)) { 
     110                FATAL("Unable to read matrix structure"); 
     111                return false; 
     112        } 
    113113 
    114     if (!ReadUInt32(_trackWidth)) { 
    115         FATAL("Unable to read track width"); 
    116         return false; 
    117     } 
    118     //FINEST("_trackWidth: %u", _trackWidth); 
     114        if (!ReadUInt32(_trackWidth)) { 
     115                FATAL("Unable to read track width"); 
     116                return false; 
     117        } 
     118        //FINEST("_trackWidth: %u", _trackWidth); 
    119119 
    120     if (!ReadUInt32(_trackHeight)) { 
    121         FATAL("Unable to read track height"); 
    122         return false; 
    123     } 
    124     //FINEST("_trackHeight: %u", _trackHeight); 
     120        if (!ReadUInt32(_trackHeight)) { 
     121                FATAL("Unable to read track height"); 
     122                return false; 
     123        } 
     124        //FINEST("_trackHeight: %u", _trackHeight); 
    125125 
    126     return true; 
     126        return true; 
    127127} 
    128128 
    129129 
     130#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomtrak.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomtrak.h" 
    2222 
     
    2525AtomTRAK::AtomTRAK(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2626: BoxAtom(pDocument, type, size, start) { 
    27     _pTKHD = NULL; 
    28     _pMDIA = NULL; 
    29     _pHDLR = NULL; 
    30     _pMINF = NULL; 
    31     _pDINF = NULL; 
    32     _pSTBL = NULL; 
    33     _pUDTA = NULL; 
     27        _pTKHD = NULL; 
     28        _pMDIA = NULL; 
     29        _pHDLR = NULL; 
     30        _pMINF = NULL; 
     31        _pDINF = NULL; 
     32        _pSTBL = NULL; 
     33        _pUDTA = NULL; 
    3434} 
    3535 
     
    3838 
    3939bool AtomTRAK::AtomCreated(BaseAtom *pAtom) { 
    40     switch (pAtom->GetTypeNumeric()) { 
    41         case A_TKHD: 
    42             _pTKHD = (AtomTKHD *) pAtom; 
    43             return true; 
    44         case A_MDIA: 
    45             _pMDIA = (AtomMDIA *) pAtom; 
    46             return true; 
    47         case A_HDLR: 
    48             _pHDLR = (AtomHDLR *) pAtom; 
    49             return true; 
    50         case A_MINF: 
    51             _pMINF = (AtomMINF *) pAtom; 
    52             return true; 
    53         case A_DINF: 
    54             _pDINF = (AtomDINF *) pAtom; 
    55             return true; 
    56         case A_STBL: 
    57             _pSTBL = (AtomSTBL *) pAtom; 
    58             return true; 
    59         case A_UDTA: 
    60             _pUDTA = (AtomUDTA *) pAtom; 
    61             return true; 
    62         case A_META: 
    63             _pMETA = (AtomMETA *) pAtom; 
    64             return true; 
    65         default: 
    66         { 
    67             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    68             return false; 
    69         } 
    70     } 
     40        switch (pAtom->GetTypeNumeric()) { 
     41                case A_TKHD: 
     42                        _pTKHD = (AtomTKHD *) pAtom; 
     43                        return true; 
     44                case A_MDIA: 
     45                        _pMDIA = (AtomMDIA *) pAtom; 
     46                        return true; 
     47                case A_HDLR: 
     48                        _pHDLR = (AtomHDLR *) pAtom; 
     49                        return true; 
     50                case A_MINF: 
     51                        _pMINF = (AtomMINF *) pAtom; 
     52                        return true; 
     53                case A_DINF: 
     54                        _pDINF = (AtomDINF *) pAtom; 
     55                        return true; 
     56                case A_STBL: 
     57                        _pSTBL = (AtomSTBL *) pAtom; 
     58                        return true; 
     59                case A_UDTA: 
     60                        _pUDTA = (AtomUDTA *) pAtom; 
     61                        return true; 
     62                case A_META: 
     63                        _pMETA = (AtomMETA *) pAtom; 
     64                        return true; 
     65                default: 
     66                { 
     67                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     68                        return false; 
     69                } 
     70        } 
    7171} 
    7272 
     73#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomudta.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomudta.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2424AtomUDTA::AtomUDTA(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2525: BoxAtom(pDocument, type, size, start) { 
    26     _pMETA = NULL; 
     26        _pMETA = NULL; 
    2727} 
    2828 
     
    3131 
    3232bool AtomUDTA::Read() { 
    33     if (_pParent == NULL) 
    34         return SkipRead(false); 
    35     if (_pParent->GetTypeNumeric() != A_MOOV) 
    36         return SkipRead(false); 
    37     return BoxAtom::Read(); 
     33        if (_pParent == NULL) 
     34                return SkipRead(false); 
     35        if (_pParent->GetTypeNumeric() != A_MOOV) 
     36                return SkipRead(false); 
     37        return BoxAtom::Read(); 
    3838} 
    3939 
    4040bool AtomUDTA::AtomCreated(BaseAtom *pAtom) { 
    41     switch (pAtom->GetTypeNumeric()) { 
    42         case A_META: 
    43             _pMETA = (AtomMETA *) pAtom; 
    44             return true; 
    45         case A_NAME: 
    46         case A__ALB: 
    47         case A__ART: 
    48         case A__CMT: 
    49         case A__CPY: 
    50         case A__DES: 
    51         case A__NAM: 
    52         case A__COM: 
    53         case A__GEN: 
    54         { 
    55             ADD_VECTOR_END(_metaFields, (AtomMetaField *) pAtom); 
    56             return true; 
    57         } 
    58         default: 
    59         { 
    60             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    61             return false; 
    62         } 
    63     } 
     41        switch (pAtom->GetTypeNumeric()) { 
     42                case A_META: 
     43                        _pMETA = (AtomMETA *) pAtom; 
     44                        return true; 
     45                case A_NAME: 
     46                case A__ALB: 
     47                case A__ART: 
     48                case A__CMT: 
     49                case A__CPY: 
     50                case A__DES: 
     51                case A__NAM: 
     52                case A__COM: 
     53                case A__GEN: 
     54                { 
     55                        ADD_VECTOR_END(_metaFields, (AtomMetaField *) pAtom); 
     56                        return true; 
     57                } 
     58                default: 
     59                { 
     60                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     61                        return false; 
     62                } 
     63        } 
    6464} 
    6565 
     66#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomurl.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomurl.h" 
    2222 
     
    3030 
    3131bool AtomURL::ReadData() { 
    32     if (!ReadString(_location, _size - 12)) { 
    33         FATAL("Unable to read location"); 
    34         return false; 
    35     } 
    36     return true; 
     32        if (!ReadString(_location, _size - 12)) { 
     33                FATAL("Unable to read location"); 
     34                return false; 
     35        } 
     36        return true; 
    3737} 
    3838 
     39#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomvmhd.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomvmhd.h" 
    2222 
    2323AtomVMHD::AtomVMHD(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2424: VersionedAtom(pDocument, type, size, start) { 
    25     _graphicsMode = 0; 
    26     memset(_opcolor, 0, 6); 
     25        _graphicsMode = 0; 
     26        memset(_opcolor, 0, 6); 
    2727} 
    2828 
     
    3131 
    3232bool AtomVMHD::ReadData() { 
    33     if (!ReadUInt16(_graphicsMode)) { 
    34         FATAL("Unable to read graphics mode"); 
    35         return false; 
    36     } 
    37     //FINEST("_graphicsMode: %u", _graphicsMode); 
     33        if (!ReadUInt16(_graphicsMode)) { 
     34                FATAL("Unable to read graphics mode"); 
     35                return false; 
     36        } 
     37        //FINEST("_graphicsMode: %u", _graphicsMode); 
    3838 
    39     if (!ReadArray(_opcolor, 6)) { 
    40         FATAL("Unable to read opcodes"); 
    41         return false; 
    42     } 
     39        if (!ReadArray(_opcolor, 6)) { 
     40                FATAL("Unable to read opcodes"); 
     41                return false; 
     42        } 
    4343 
    44     return true; 
     44        return true; 
    4545} 
    4646 
    4747 
     48#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/atomwave.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/atomwave.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    2424AtomWAVE::AtomWAVE(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) 
    2525: BoxAtom(pDocument, type, size, start) { 
    26     _pMP4A = NULL; 
    27     _pESDS = NULL; 
     26        _pMP4A = NULL; 
     27        _pESDS = NULL; 
    2828} 
    2929 
     
    3232 
    3333bool AtomWAVE::AtomCreated(BaseAtom *pAtom) { 
    34     switch (pAtom->GetTypeNumeric()) { 
    35         case A_MP4A: 
    36             _pMP4A = (AtomMP4A *) pAtom; 
    37             return true; 
    38         case A_ESDS: 
    39             _pESDS = (AtomESDS *) pAtom; 
    40             return true; 
    41         case 0://NULL atom 
    42             //WARN("Ignoring NULL atom"); 
    43             return true; 
    44         default: 
    45         { 
    46             FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
    47             return false; 
    48         } 
    49     } 
     34        switch (pAtom->GetTypeNumeric()) { 
     35                case A_MP4A: 
     36                        _pMP4A = (AtomMP4A *) pAtom; 
     37                        return true; 
     38                case A_ESDS: 
     39                        _pESDS = (AtomESDS *) pAtom; 
     40                        return true; 
     41                case 0://NULL atom 
     42                        //WARN("Ignoring NULL atom"); 
     43                        return true; 
     44                default: 
     45                { 
     46                        FATAL("Invalid atom type: %s", STR(pAtom->GetTypeString())); 
     47                        return false; 
     48                } 
     49        } 
    5050} 
    5151 
    5252 
     53#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/baseatom.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
    21  
     21#ifdef HAS_MEDIA_MP4 
    2222#include "mediaformats/mp4/baseatom.h" 
    2323#include "mediaformats/mp4/mp4document.h" 
    2424 
    2525string U32TOS(uint32_t type) { 
    26     type = ntohl(type); 
    27     return string((char *) & (type), 4); 
     26        type = ntohl(type); 
     27        return string((char *) & (type), 4); 
    2828} 
    2929 
    3030BaseAtom::BaseAtom(MP4Document *pDocument, uint32_t type, uint64_t size, uint64_t start) { 
    31     _pDoc = pDocument; 
    32     _pParent = NULL; 
    33     _pDoc->AddAtom(this); 
    34     _type = type; 
    35     _size = size; 
    36     _start = start; 
    37     //FINEST("Atom created: %p", this); 
     31        _pDoc = pDocument; 
     32        _pParent = NULL; 
     33        _pDoc->AddAtom(this); 
     34        _type = type; 
     35        _size = size; 
     36        _start = start; 
     37        //FINEST("Atom created: %p", this); 
    3838} 
    3939 
    4040BaseAtom::~BaseAtom() { 
    41     //FINEST("Atom deleted: %p", this); 
     41        //FINEST("Atom deleted: %p", this); 
    4242} 
    4343 
    4444uint64_t BaseAtom::GetStart() { 
    45     return _start; 
     45        return _start; 
    4646} 
    4747 
    4848uint64_t BaseAtom::GetSize() { 
    49     return _size; 
     49        return _size; 
    5050} 
    5151 
    5252string BaseAtom::GetTypeString() { 
    53     return U32TOS(_type); 
     53        return U32TOS(_type); 
    5454} 
    5555 
    5656uint32_t BaseAtom::GetTypeNumeric() { 
    57     return _type; 
     57        return _type; 
    5858} 
    5959 
    6060MP4Document * BaseAtom::GetDoc() { 
    61     return _pDoc; 
     61        return _pDoc; 
    6262} 
    6363 
    6464BaseAtom::operator string() { 
    65     return format("S: %llu(0x%llx); L: %llu(0x%llx); T: %d(%s)", 
    66             _start, _start, _size, _size, GetTypeNumeric(), STR(GetTypeString())); 
     65        return format("S: %llu(0x%llx); L: %llu(0x%llx); T: %d(%s)", 
     66                        _start, _start, _size, _size, GetTypeNumeric(), STR(GetTypeString())); 
    6767} 
    6868 
    6969bool BaseAtom::IsIgnored() { 
    70     return false; 
     70        return false; 
    7171} 
    7272 
    7373BaseAtom * BaseAtom::GetPath(vector<uint32_t> path) { 
    74     ASSERT("Operation not supported"); 
    75     return NULL; 
     74        ASSERT("Operation not supported"); 
     75        return NULL; 
    7676} 
    7777 
    7878BaseAtom *BaseAtom::GetParentAtom() { 
    79     return _pParent; 
     79        return _pParent; 
    8080} 
    8181 
    8282void BaseAtom::SetParentAtom(BaseAtom *pParent) { 
    83     _pParent = pParent; 
     83        _pParent = pParent; 
    8484} 
    8585 
    8686bool BaseAtom::SkipRead(bool issueWarn) { 
    87     if (issueWarn) 
    88         WARN("Atom type %s skipped. Position 0x%llx(%llu); Size: 0x%llx(%llu)", 
    89             STR(GetTypeString()), _start, _start, _size, _size); 
    90     return _pDoc->GetMediaFile().SeekTo(_start + _size); 
     87        if (issueWarn) 
     88                WARN("Atom type %s skipped. Position 0x%llx(%llu); Size: 0x%llx(%llu)", 
     89                        STR(GetTypeString()), _start, _start, _size, _size); 
     90        return _pDoc->GetMediaFile().SeekTo(_start + _size); 
    9191} 
    9292 
    9393uint64_t BaseAtom::CurrentPosition() { 
    94     return _pDoc->GetMediaFile().Cursor(); 
     94        return _pDoc->GetMediaFile().Cursor(); 
    9595} 
    9696 
    9797bool BaseAtom::CheckBounds(uint64_t size) { 
    98     if (CurrentPosition() + size > _start + _size) { 
    99         FATAL("Reached the end of the atom: Current pos: %llu; Wanted size: %d; atom start: %d; atom size: %d", 
    100                 CurrentPosition(), size, _start, _size); 
    101         return false; 
    102     } 
    103     return true; 
     98        if (CurrentPosition() + size > _start + _size) { 
     99                FATAL("Reached the end of the atom: Current pos: %llu; Wanted size: %d; atom start: %d; atom size: %d", 
     100                                CurrentPosition(), size, _start, _size); 
     101                return false; 
     102        } 
     103        return true; 
    104104} 
    105105 
    106106bool BaseAtom::ReadArray(uint8_t *pBuffer, uint64_t length) { 
    107     if (!CheckBounds(length)) 
    108         return false; 
    109     return _pDoc->GetMediaFile().ReadBuffer(pBuffer, length); 
     107        if (!CheckBounds(length)) 
     108                return false; 
     109        return _pDoc->GetMediaFile().ReadBuffer(pBuffer, length); 
    110110} 
    111111 
    112112bool BaseAtom::ReadUInt8(uint8_t &val) { 
    113     if (!CheckBounds(1)) 
    114         return false; 
    115     return _pDoc->GetMediaFile().ReadUI8(& val); 
     113        if (!CheckBounds(1)) 
     114                return false; 
     115        return _pDoc->GetMediaFile().ReadUI8(& val); 
    116116} 
    117117 
    118118bool BaseAtom::ReadUInt16(uint16_t &val, bool networkOrder) { 
    119     if (!CheckBounds(2)) 
    120         return false; 
    121     return _pDoc->GetMediaFile().ReadUI16(& val, networkOrder); 
     119        if (!CheckBounds(2)) 
     120                return false; 
     121        return _pDoc->GetMediaFile().ReadUI16(& val, networkOrder); 
    122122} 
    123123 
    124124bool BaseAtom::ReadInt16(int16_t &val, bool networkOrder) { 
    125     if (!CheckBounds(2)) 
    126         return false; 
    127     return _pDoc->GetMediaFile().ReadI16(& val, networkOrder); 
     125        if (!CheckBounds(2)) 
     126                return false; 
     127        return _pDoc->GetMediaFile().ReadI16(& val, networkOrder); 
    128128} 
    129129 
    130130bool BaseAtom::ReadUInt24(uint32_t &val, bool networkOrder) { 
    131     if (!CheckBounds(3)) 
    132         return false; 
    133     return _pDoc->GetMediaFile().ReadUI24(&val, networkOrder); 
     131        if (!CheckBounds(3)) 
     132                return false; 
     133        return _pDoc->GetMediaFile().ReadUI24(&val, networkOrder); 
    134134} 
    135135 
    136136bool BaseAtom::ReadUInt32(uint32_t &val, bool networkOrder) { 
    137     if (!CheckBounds(4)) 
    138         return false; 
    139     return _pDoc->GetMediaFile().ReadUI32(&val, networkOrder); 
     137        if (!CheckBounds(4)) 
     138                return false; 
     139        return _pDoc->GetMediaFile().ReadUI32(&val, networkOrder); 
    140140} 
    141141 
    142142bool BaseAtom::ReadInt32(int32_t &val, bool networkOrder) { 
    143     if (!CheckBounds(4)) 
    144         return false; 
    145     return _pDoc->GetMediaFile().ReadI32(&val, networkOrder); 
     143        if (!CheckBounds(4)) 
     144                return false; 
     145        return _pDoc->GetMediaFile().ReadI32(&val, networkOrder); 
    146146} 
    147147 
    148148bool BaseAtom::ReadUInt64(uint64_t &val, bool networkOrder) { 
    149     if (!CheckBounds(8)) 
    150         return false; 
    151     return _pDoc->GetMediaFile().ReadUI64(&val, networkOrder); 
     149        if (!CheckBounds(8)) 
     150                return false; 
     151        return _pDoc->GetMediaFile().ReadUI64(&val, networkOrder); 
    152152} 
    153153 
    154154bool BaseAtom::ReadInt64(int64_t &val, bool networkOrder) { 
    155     if (!CheckBounds(8)) 
    156         return false; 
    157     return _pDoc->GetMediaFile().ReadI64(&val, networkOrder); 
     155        if (!CheckBounds(8)) 
     156                return false; 
     157        return _pDoc->GetMediaFile().ReadI64(&val, networkOrder); 
    158158} 
    159159 
    160160bool BaseAtom::SkipBytes(uint64_t count) { 
    161     if (!CheckBounds(count)) 
    162         return false; 
    163     return _pDoc->GetMediaFile().SeekAhead(count); 
     161        if (!CheckBounds(count)) 
     162                return false; 
     163        return _pDoc->GetMediaFile().SeekAhead(count); 
    164164} 
    165165 
    166166bool BaseAtom::ReadString(string &val, uint64_t size) { 
    167     if (!CheckBounds(size)) 
    168         return false; 
    169     char *pTemp = new char[size + 1]; 
    170     memset(pTemp, 0, size + 1); 
    171     bool result = _pDoc->GetMediaFile().ReadBuffer((uint8_t *) pTemp, size); 
    172     if (result) 
    173         val = string(pTemp, size); 
    174     else 
    175         val = ""; 
    176     delete[] pTemp; 
    177     return result; 
     167        if (!CheckBounds(size)) 
     168                return false; 
     169        char *pTemp = new char[size + 1]; 
     170        memset(pTemp, 0, size + 1); 
     171        bool result = _pDoc->GetMediaFile().ReadBuffer((uint8_t *) pTemp, size); 
     172        if (result) 
     173                val = string(pTemp, size); 
     174        else 
     175                val = ""; 
     176        delete[] pTemp; 
     177        return result; 
    178178} 
    179179 
     180#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/boxatom.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
    21  
     21#ifdef HAS_MEDIA_MP4 
    2222#include "mediaformats/mp4/boxatom.h" 
    2323#include "mediaformats/mp4/mp4document.h" 
     
    3232 
    3333bool BoxAtom::Read() { 
    34     while (CurrentPosition() != _start + _size) { 
    35         BaseAtom *pAtom = GetDoc()->ReadAtom(this); 
    36         if (pAtom == NULL) { 
    37             FATAL("Unable to read atom. Parent atom is %s", 
    38                     STR(GetTypeString())); 
    39             return false; 
    40         } 
    41         if (!pAtom->IsIgnored()) { 
    42             //FINEST("pAtom: %p (%s)", pAtom, STR(pAtom->GetTypeString())); 
    43             if (!AtomCreated(pAtom)) { 
    44                 FATAL("Unable to signal AtomCreated for atom %s (%x)", 
    45                         STR(GetTypeString()), _start); 
    46                 return false; 
    47             } 
    48         } 
    49         ADD_VECTOR_END(_subAtoms, pAtom); 
    50     } 
    51     //    FINEST("Atom %s has %d subatoms", STR(GetTypeString())  , 
    52     //            (uint32_t) _subAtoms.size()); 
    53     return true; 
     34        while (CurrentPosition() != _start + _size) { 
     35                BaseAtom *pAtom = GetDoc()->ReadAtom(this); 
     36                if (pAtom == NULL) { 
     37                        FATAL("Unable to read atom. Parent atom is %s", 
     38                                        STR(GetTypeString())); 
     39                        return false; 
     40                } 
     41                if (!pAtom->IsIgnored()) { 
     42                        //FINEST("pAtom: %p (%s)", pAtom, STR(pAtom->GetTypeString())); 
     43                        if (!AtomCreated(pAtom)) { 
     44                                FATAL("Unable to signal AtomCreated for atom %s (%x)", 
     45                                                STR(GetTypeString()), _start); 
     46                                return false; 
     47                        } 
     48                } 
     49                ADD_VECTOR_END(_subAtoms, pAtom); 
     50        } 
     51        //    FINEST("Atom %s has %d subatoms", STR(GetTypeString())  , 
     52        //            (uint32_t) _subAtoms.size()); 
     53        return true; 
    5454} 
    5555 
    5656string BoxAtom::Hierarchy(uint32_t indent) { 
    57     string result = string(indent * 4, ' ') + GetTypeString() + "\n"; 
    58     //FINEST("%d %s", indent, STR(result)); 
    59     if (_subAtoms.size() == 0) { 
    60         result += string((indent + 1) * 4, ' ') + "[empty]"; 
    61         return result; 
    62     } 
    63     for (uint32_t i = 0; i < _subAtoms.size(); i++) { 
    64         result += _subAtoms[i]->Hierarchy(indent + 1); 
    65         if (i != _subAtoms.size() - 1) 
    66             result += "\n"; 
    67     } 
    68     return result; 
     57        string result = string(indent * 4, ' ') + GetTypeString() + "\n"; 
     58        //FINEST("%d %s", indent, STR(result)); 
     59        if (_subAtoms.size() == 0) { 
     60                result += string((indent + 1) * 4, ' ') + "[empty]"; 
     61                return result; 
     62        } 
     63        for (uint32_t i = 0; i < _subAtoms.size(); i++) { 
     64                result += _subAtoms[i]->Hierarchy(indent + 1); 
     65                if (i != _subAtoms.size() - 1) 
     66                        result += "\n"; 
     67        } 
     68        return result; 
    6969} 
    7070 
    7171BaseAtom * BoxAtom::GetPath(uint8_t depth, ...) { 
    72     vector<uint32_t> path; 
    73     va_list arguments; 
    74     va_start(arguments, depth); 
    75     //string strPath = ""; 
    76     for (uint8_t i = 0; i < depth; i++) { 
    77         uint32_t pathElement = va_arg(arguments, uint32_t); 
    78         //strPath += format("%s->", STR(U32TOS(pathElement))); 
    79         ADD_VECTOR_END(path, pathElement); 
    80     } 
    81     va_end(arguments); 
    82     //FINEST("Path: %s", STR(strPath)); 
    83     if (path.size() == 0) 
    84         return NULL; 
    85     return GetPath(path); 
     72        vector<uint32_t> path; 
     73        va_list arguments; 
     74        va_start(arguments, depth); 
     75        //string strPath = ""; 
     76        for (uint8_t i = 0; i < depth; i++) { 
     77                uint32_t pathElement = va_arg(arguments, uint32_t); 
     78                //strPath += format("%s->", STR(U32TOS(pathElement))); 
     79                ADD_VECTOR_END(path, pathElement); 
     80        } 
     81        va_end(arguments); 
     82        //FINEST("Path: %s", STR(strPath)); 
     83        if (path.size() == 0) 
     84                return NULL; 
     85        return GetPath(path); 
    8686} 
    8787 
    8888BaseAtom * BoxAtom::GetPath(vector<uint32_t> path) { 
    89     if (path.size() == 0) 
    90         return NULL; 
     89        if (path.size() == 0) 
     90                return NULL; 
    9191 
    92     uint32_t search = path[0]; 
    93     path.erase(path.begin()); 
    94     for (uint32_t i = 0; i < _subAtoms.size(); i++) { 
    95         //        FINEST("Wanted s: %s; Got s: %s; Wanted: %08x; Got: %08x", 
    96         //                STR(U32TOS(search)), 
    97         //                STR(_subAtoms[i]->GetTypeString()), 
    98         //                search, 
    99         //                _subAtoms[i]->GetTypeNumeric()); 
    100         if (_subAtoms[i]->GetTypeNumeric() == search) { 
    101             if (path.size() == 0) 
    102                 return _subAtoms[i]; 
    103             return _subAtoms[i]->GetPath(path); 
    104         } 
    105     } 
     92        uint32_t search = path[0]; 
     93        path.erase(path.begin()); 
     94        for (uint32_t i = 0; i < _subAtoms.size(); i++) { 
     95                //        FINEST("Wanted s: %s; Got s: %s; Wanted: %08x; Got: %08x", 
     96                //                STR(U32TOS(search)), 
     97                //                STR(_subAtoms[i]->GetTypeString()), 
     98                //                search, 
     99                //                _subAtoms[i]->GetTypeNumeric()); 
     100                if (_subAtoms[i]->GetTypeNumeric() == search) { 
     101                        if (path.size() == 0) 
     102                                return _subAtoms[i]; 
     103                        return _subAtoms[i]->GetPath(path); 
     104                } 
     105        } 
    106106 
    107     return NULL; 
     107        return NULL; 
    108108} 
    109109 
     110#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/ignoredatom.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/ignoredatom.h" 
    2222 
     
    3030 
    3131bool IgnoredAtom::IsIgnored() { 
    32     return true; 
     32        return true; 
    3333} 
    3434 
    3535bool IgnoredAtom::Read() { 
    36     return SkipRead(); 
     36        return SkipRead(); 
    3737} 
    3838 
    3939string IgnoredAtom::Hierarchy(uint32_t indent) { 
    40     return string(4 * indent, ' ') + GetTypeString(); 
     40        return string(4 * indent, ' ') + GetTypeString(); 
    4141} 
    4242 
     43#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/mp4document.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
    19  
    20  
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
     19 
     20#ifdef HAS_MEDIA_MP4 
    2121#include "utils/file.h" 
    2222#include "mediaformats/mp4/mp4document.h" 
     
    6363MP4Document::MP4Document(Variant &metadata) 
    6464: BaseMediaDocument(metadata) { 
    65     _pFTYP = NULL; 
    66     _pMOOV = NULL; 
     65        _pFTYP = NULL; 
     66        _pMOOV = NULL; 
    6767} 
    6868 
    6969MP4Document::~MP4Document() { 
    7070 
    71     FOR_VECTOR_ITERATOR(BaseAtom *, _allAtoms, i) { 
    72         delete VECTOR_VAL(i); 
    73     } 
    74     _allAtoms.clear(); 
     71        FOR_VECTOR_ITERATOR(BaseAtom *, _allAtoms, i) { 
     72                delete VECTOR_VAL(i); 
     73        } 
     74        _allAtoms.clear(); 
    7575} 
    7676 
    7777#ifdef HAS_MMAP 
     78 
    7879MmapFile &MP4Document::GetMediaFile() { 
    79     return _mediaFile; 
     80        return _mediaFile; 
    8081} 
    8182#else 
     83 
    8284File &MP4Document::GetMediaFile() { 
    83     return _mediaFile; 
     85        return _mediaFile; 
    8486} 
    8587#endif /* HAS_MMAP */ 
    8688 
    8789void MP4Document::AddAtom(BaseAtom *pAtom) { 
    88     ADD_VECTOR_END(_allAtoms, pAtom); 
     90        ADD_VECTOR_END(_allAtoms, pAtom); 
    8991} 
    9092 
    9193BaseAtom * MP4Document::ReadAtom(BaseAtom *pParentAtom) { 
    92     uint64_t currentPos = _mediaFile.Cursor(); 
    93  
    94     uint64_t size = 0; 
    95     uint32_t type = 0; 
    96     BaseAtom *pAtom = NULL; 
    97  
    98     uint32_t size32 = 0; 
    99     if (!_mediaFile.ReadUI32(& size32)) { 
    100         FATAL("Unable to read atom size"); 
    101         return NULL; 
    102     } 
    103  
    104     size = size32; 
    105  
    106     if (size == 0) { 
    107         pAtom = new AtomNULL(this, type, size, currentPos); 
    108         pAtom->SetParentAtom(pParentAtom); 
    109         return pAtom; 
    110     } 
    111  
    112     if (!_mediaFile.ReadUI32(&type)) { 
    113         FATAL("Unable to read atom type"); 
    114         return NULL; 
    115     } 
    116  
    117     if (size == 1) { 
    118         if (!_mediaFile.ReadUI64(& size)) { 
    119             FATAL("Unable to read atom size"); 
    120             return NULL; 
    121         } 
    122  
    123         if (size == 0) { 
    124             pAtom = new AtomNULL(this, type, size, currentPos); 
    125             pAtom->SetParentAtom(pParentAtom); 
    126             return pAtom; 
    127         } 
    128     } 
    129  
    130     switch (type) { 
    131         case A_FTYP: 
    132             pAtom = new AtomFTYP(this, type, size, currentPos); 
    133             break; 
    134         case A_MOOV: 
    135             pAtom = new AtomMOOV(this, type, size, currentPos); 
    136             break; 
    137         case A_MVHD: 
    138             pAtom = new AtomMVHD(this, type, size, currentPos); 
    139             break; 
    140         case A_TRAK: 
    141             pAtom = new AtomTRAK(this, type, size, currentPos); 
    142             break; 
    143         case A_TKHD: 
    144             pAtom = new AtomTKHD(this, type, size, currentPos); 
    145             break; 
    146         case A_MDIA: 
    147             pAtom = new AtomMDIA(this, type, size, currentPos); 
    148             break; 
    149         case A_MDHD: 
    150             pAtom = new AtomMDHD(this, type, size, currentPos); 
    151             break; 
    152         case A_HDLR: 
    153             pAtom = new AtomHDLR(this, type, size, currentPos); 
    154             break; 
    155         case A_MINF: 
    156             pAtom = new AtomMINF(this, type, size, currentPos); 
    157             break; 
    158         case A_SMHD: 
    159             pAtom = new AtomSMHD(this, type, size, currentPos); 
    160             break; 
    161         case A_DINF: 
    162             pAtom = new AtomDINF(this, type, size, currentPos); 
    163             break; 
    164         case A_STBL: 
    165             pAtom = new AtomSTBL(this, type, size, currentPos); 
    166             break; 
    167         case A_VMHD: 
    168             pAtom = new AtomVMHD(this, type, size, currentPos); 
    169             break; 
    170         case A_DREF: 
    171             pAtom = new AtomDREF(this, type, size, currentPos); 
    172             break; 
    173         case A_STSD: 
    174             pAtom = new AtomSTSD(this, type, size, currentPos); 
    175             break; 
    176         case A_STTS: 
    177             pAtom = new AtomSTTS(this, type, size, currentPos); 
    178             break; 
    179         case A_STSC: 
    180             pAtom = new AtomSTSC(this, type, size, currentPos); 
    181             break; 
    182         case A_STSZ: 
    183             pAtom = new AtomSTSZ(this, type, size, currentPos); 
    184             break; 
    185         case A_STCO: 
    186             pAtom = new AtomSTCO(this, type, size, currentPos); 
    187             break; 
    188         case A_CTTS: 
    189             pAtom = new AtomCTTS(this, type, size, currentPos); 
    190             break; 
    191         case A_STSS: 
    192             pAtom = new AtomSTSS(this, type, size, currentPos); 
    193             break; 
    194         case A_URL: 
    195             pAtom = new AtomURL(this, type, size, currentPos); 
    196             break; 
    197         case A_MP4A: 
    198             pAtom = new AtomMP4A(this, type, size, currentPos); 
    199             break; 
    200         case A_AVC1: 
    201             pAtom = new AtomAVC1(this, type, size, currentPos); 
    202             break; 
    203         case A_ESDS: 
    204             pAtom = new AtomESDS(this, type, size, currentPos); 
    205             break; 
    206         case A_AVCC: 
    207             pAtom = new AtomAVCC(this, type, size, currentPos); 
    208             break; 
    209         case A_UDTA: 
    210             pAtom = new AtomUDTA(this, type, size, currentPos); 
    211             break; 
    212         case A_WAVE: 
    213             pAtom = new AtomWAVE(this, type, size, currentPos); 
    214             break; 
    215         case A_META: 
    216             pAtom = new AtomMETA(this, type, size, currentPos); 
    217             break; 
    218         case A_NULL: 
    219             pAtom = new AtomNULL(this, type, size, currentPos); 
    220             break; 
    221         case A_ILST: 
    222             pAtom = new AtomILST(this, type, size, currentPos); 
    223             break; 
    224         case A_DATA: 
    225             pAtom = new AtomDATA(this, type, size, currentPos); 
    226             break; 
    227         case A_CO64: 
    228             pAtom = new AtomCO64(this, type, size, currentPos); 
    229             break; 
    230         case A__COM: 
    231         case A_NAME: 
    232         case A_COVR: 
    233         case A_AART: 
    234         case A__WRT: 
    235         case A__GRP: 
    236         case A__LYR: 
    237         case A__NAM: 
    238         case A__TOO: 
    239         case A__DAY: 
    240         case A__CMT: 
    241         case A__CPY: 
    242         case A__DES: 
    243         case A__ART: 
    244         case A__ALB: 
    245         case A_TRKN: 
    246         case A_CPIL: 
    247         case A_PGAP: 
    248         case A_TMPO: 
    249         case A_GNRE: 
    250         case A_DISK: 
    251         case A__GEN: 
    252         case A_DESC: 
    253         case A_TVSH: 
    254         case A_TVEN: 
    255         case A_TVSN: 
    256         case A_TVES: 
    257             pAtom = new AtomMetaField(this, type, size, currentPos); 
    258             break; 
    259         default: 
    260         { 
    261             //            FATAL("Atom type %s(%u) not yet implemented. Position: 0x%x", 
    262             //                    STR(U32TOS(type)), type, (uint32_t) _mediaFile.Cursor()); 
    263             //            return NULL; 
    264             pAtom = new IgnoredAtom(this, type, size, currentPos); 
    265             break; 
    266         } 
    267     } 
    268  
    269     pAtom->SetParentAtom(pParentAtom); 
    270  
    271     if (!pAtom->Read()) { 
    272         FATAL("Unable to read atom type %s", STR(U32TOS(type))); 
    273         return NULL; 
    274     } 
    275  
    276     //    FINEST("END reading atom %s at 0x%x with size 0x%x", 
    277     //            STR(U32TOS(type)), currentPos, size); 
    278  
    279     if (currentPos + pAtom->GetSize() != _mediaFile.Cursor()) { 
    280         FATAL("atom start: %llu; Atom size: %llu; currentPos: %llu", 
    281                 currentPos, pAtom->GetSize(), _mediaFile.Cursor()); 
    282         return NULL; 
    283     } 
    284     return pAtom; 
     94        uint64_t currentPos = _mediaFile.Cursor(); 
     95 
     96        uint64_t size = 0; 
     97        uint32_t type = 0; 
     98        BaseAtom *pAtom = NULL; 
     99 
     100        uint32_t size32 = 0; 
     101        if (!_mediaFile.ReadUI32(& size32)) { 
     102                FATAL("Unable to read atom size"); 
     103                return NULL; 
     104        } 
     105 
     106        size = size32; 
     107 
     108        if (size == 0) { 
     109                pAtom = new AtomNULL(this, type, size, currentPos); 
     110                pAtom->SetParentAtom(pParentAtom); 
     111                return pAtom; 
     112        } 
     113 
     114        if (!_mediaFile.ReadUI32(&type)) { 
     115                FATAL("Unable to read atom type"); 
     116                return NULL; 
     117        } 
     118 
     119        if (size == 1) { 
     120                if (!_mediaFile.ReadUI64(& size)) { 
     121                        FATAL("Unable to read atom size"); 
     122                        return NULL; 
     123                } 
     124 
     125                if (size == 0) { 
     126                        pAtom = new AtomNULL(this, type, size, currentPos); 
     127                        pAtom->SetParentAtom(pParentAtom); 
     128                        return pAtom; 
     129                } 
     130        } 
     131 
     132        switch (type) { 
     133                case A_FTYP: 
     134                        pAtom = new AtomFTYP(this, type, size, currentPos); 
     135                        break; 
     136                case A_MOOV: 
     137                        pAtom = new AtomMOOV(this, type, size, currentPos); 
     138                        break; 
     139                case A_MVHD: 
     140                        pAtom = new AtomMVHD(this, type, size, currentPos); 
     141                        break; 
     142                case A_TRAK: 
     143                        pAtom = new AtomTRAK(this, type, size, currentPos); 
     144                        break; 
     145                case A_TKHD: 
     146                        pAtom = new AtomTKHD(this, type, size, currentPos); 
     147                        break; 
     148                case A_MDIA: 
     149                        pAtom = new AtomMDIA(this, type, size, currentPos); 
     150                        break; 
     151                case A_MDHD: 
     152                        pAtom = new AtomMDHD(this, type, size, currentPos); 
     153                        break; 
     154                case A_HDLR: 
     155                        pAtom = new AtomHDLR(this, type, size, currentPos); 
     156                        break; 
     157                case A_MINF: 
     158                        pAtom = new AtomMINF(this, type, size, currentPos); 
     159                        break; 
     160                case A_SMHD: 
     161                        pAtom = new AtomSMHD(this, type, size, currentPos); 
     162                        break; 
     163                case A_DINF: 
     164                        pAtom = new AtomDINF(this, type, size, currentPos); 
     165                        break; 
     166                case A_STBL: 
     167                        pAtom = new AtomSTBL(this, type, size, currentPos); 
     168                        break; 
     169                case A_VMHD: 
     170                        pAtom = new AtomVMHD(this, type, size, currentPos); 
     171                        break; 
     172                case A_DREF: 
     173                        pAtom = new AtomDREF(this, type, size, currentPos); 
     174                        break; 
     175                case A_STSD: 
     176                        pAtom = new AtomSTSD(this, type, size, currentPos); 
     177                        break; 
     178                case A_STTS: 
     179                        pAtom = new AtomSTTS(this, type, size, currentPos); 
     180                        break; 
     181                case A_STSC: 
     182                        pAtom = new AtomSTSC(this, type, size, currentPos); 
     183                        break; 
     184                case A_STSZ: 
     185                        pAtom = new AtomSTSZ(this, type, size, currentPos); 
     186                        break; 
     187                case A_STCO: 
     188                        pAtom = new AtomSTCO(this, type, size, currentPos); 
     189                        break; 
     190                case A_CTTS: 
     191                        pAtom = new AtomCTTS(this, type, size, currentPos); 
     192                        break; 
     193                case A_STSS: 
     194                        pAtom = new AtomSTSS(this, type, size, currentPos); 
     195                        break; 
     196                case A_URL: 
     197                        pAtom = new AtomURL(this, type, size, currentPos); 
     198                        break; 
     199                case A_MP4A: 
     200                        pAtom = new AtomMP4A(this, type, size, currentPos); 
     201                        break; 
     202                case A_AVC1: 
     203                        pAtom = new AtomAVC1(this, type, size, currentPos); 
     204                        break; 
     205                case A_ESDS: 
     206                        pAtom = new AtomESDS(this, type, size, currentPos); 
     207                        break; 
     208                case A_AVCC: 
     209                        pAtom = new AtomAVCC(this, type, size, currentPos); 
     210                        break; 
     211                case A_UDTA: 
     212                        pAtom = new AtomUDTA(this, type, size, currentPos); 
     213                        break; 
     214                case A_WAVE: 
     215                        pAtom = new AtomWAVE(this, type, size, currentPos); 
     216                        break; 
     217                case A_META: 
     218                        pAtom = new AtomMETA(this, type, size, currentPos); 
     219                        break; 
     220                case A_NULL: 
     221                        pAtom = new AtomNULL(this, type, size, currentPos); 
     222                        break; 
     223                case A_ILST: 
     224                        pAtom = new AtomILST(this, type, size, currentPos); 
     225                        break; 
     226                case A_DATA: 
     227                        pAtom = new AtomDATA(this, type, size, currentPos); 
     228                        break; 
     229                case A_CO64: 
     230                        pAtom = new AtomCO64(this, type, size, currentPos); 
     231                        break; 
     232                case A__COM: 
     233                case A_NAME: 
     234                case A_COVR: 
     235                case A_AART: 
     236                case A__WRT: 
     237                case A__GRP: 
     238                case A__LYR: 
     239                case A__NAM: 
     240                case A__TOO: 
     241                case A__DAY: 
     242                case A__CMT: 
     243                case A__CPY: 
     244                case A__DES: 
     245                case A__ART: 
     246                case A__ALB: 
     247                case A_TRKN: 
     248                case A_CPIL: 
     249                case A_PGAP: 
     250                case A_TMPO: 
     251                case A_GNRE: 
     252                case A_DISK: 
     253                case A__GEN: 
     254                case A_DESC: 
     255                case A_TVSH: 
     256                case A_TVEN: 
     257                case A_TVSN: 
     258                case A_TVES: 
     259                        pAtom = new AtomMetaField(this, type, size, currentPos); 
     260                        break; 
     261                default: 
     262                { 
     263                        //            FATAL("Atom type %s(%u) not yet implemented. Position: 0x%x", 
     264                        //                    STR(U32TOS(type)), type, (uint32_t) _mediaFile.Cursor()); 
     265                        //            return NULL; 
     266                        pAtom = new IgnoredAtom(this, type, size, currentPos); 
     267                        break; 
     268                } 
     269        } 
     270 
     271        pAtom->SetParentAtom(pParentAtom); 
     272 
     273        if (!pAtom->Read()) { 
     274                FATAL("Unable to read atom type %s", STR(U32TOS(type))); 
     275                return NULL; 
     276        } 
     277 
     278        //    FINEST("END reading atom %s at 0x%x with size 0x%x", 
     279        //            STR(U32TOS(type)), currentPos, size); 
     280 
     281        if (currentPos + pAtom->GetSize() != _mediaFile.Cursor()) { 
     282                FATAL("atom start: %llu; Atom size: %llu; currentPos: %llu", 
     283                                currentPos, pAtom->GetSize(), _mediaFile.Cursor()); 
     284                return NULL; 
     285        } 
     286        return pAtom; 
    285287} 
    286288 
    287289bool MP4Document::ParseDocument() { 
    288290 
    289     if (!_mediaFile.SeekBegin()) { 
    290         FATAL("Unable to seek to the begining of file"); 
    291         return false; 
    292     } 
    293  
    294  
    295     while (!_mediaFile.Failed()) { 
    296         uint64_t currentPos = _mediaFile.Cursor(); 
    297         if (currentPos == _mediaFile.Size()) { 
    298             FINEST("\n%s", STR(Hierarchy())); 
    299             return true; 
    300         } 
    301         BaseAtom *pAtom = ReadAtom(NULL); 
    302         if (pAtom == NULL) { 
    303             FATAL("Unable to read atom"); 
    304             return false; 
    305         } 
    306         if (!pAtom->IsIgnored()) { 
    307             switch (pAtom->GetTypeNumeric()) { 
    308                 case A_FTYP: 
    309                     _pFTYP = (AtomFTYP *) pAtom; 
    310                     break; 
    311                 case A_MOOV: 
    312                     _pMOOV = (AtomMOOV *) pAtom; 
    313                     break; 
    314                 default: 
    315                 { 
    316                     FATAL("Invalid atom %s", STR(pAtom->GetTypeString())); 
    317                     return false; 
    318                 } 
    319             } 
    320         } 
    321         ADD_VECTOR_END(_topAtoms, pAtom); 
    322     } 
    323  
    324     return true; 
     291        if (!_mediaFile.SeekBegin()) { 
     292                FATAL("Unable to seek to the begining of file"); 
     293                return false; 
     294        } 
     295 
     296 
     297        while (!_mediaFile.Failed()) { 
     298                uint64_t currentPos = _mediaFile.Cursor(); 
     299                if (currentPos == _mediaFile.Size()) { 
     300                        FINEST("\n%s", STR(Hierarchy())); 
     301                        return true; 
     302                } 
     303                BaseAtom *pAtom = ReadAtom(NULL); 
     304                if (pAtom == NULL) { 
     305                        FATAL("Unable to read atom"); 
     306                        return false; 
     307                } 
     308                if (!pAtom->IsIgnored()) { 
     309                        switch (pAtom->GetTypeNumeric()) { 
     310                                case A_FTYP: 
     311                                        _pFTYP = (AtomFTYP *) pAtom; 
     312                                        break; 
     313                                case A_MOOV: 
     314                                        _pMOOV = (AtomMOOV *) pAtom; 
     315                                        break; 
     316                                default: 
     317                                { 
     318                                        FATAL("Invalid atom %s", STR(pAtom->GetTypeString())); 
     319                                        return false; 
     320                                } 
     321                        } 
     322                } 
     323                ADD_VECTOR_END(_topAtoms, pAtom); 
     324        } 
     325 
     326        return true; 
    325327} 
    326328 
    327329bool MP4Document::BuildFrames() { 
    328     _frames.clear(); 
    329  
    330     AtomTRAK *pTrack; 
    331     AtomAVCC *pAVCC = NULL; 
    332     if ((pTrack = GetTRAK(false)) != NULL) { 
    333         pAVCC = (AtomAVCC *) pTrack->GetPath(6, A_MDIA, A_MINF, 
    334                 A_STBL, A_STSD, A_AVC1, A_AVCC); 
    335     } 
    336  
    337     AtomESDS *pESDS = NULL; 
    338     if ((pTrack = GetTRAK(true)) != NULL) { 
    339         pESDS = (AtomESDS *) pTrack->GetPath(6, A_MDIA, A_MINF, 
    340                 A_STBL, A_STSD, A_MP4A, A_ESDS); 
    341         if (pESDS == NULL) { 
    342             pESDS = (AtomESDS *) pTrack->GetPath(7, A_MDIA, A_MINF, 
    343                     A_STBL, A_STSD, A_MP4A, A_WAVE, A_ESDS); 
    344         } 
    345     } 
    346  
    347     if (pESDS != NULL) { 
    348         //Build audio frames 
    349         if (!BuildFrames(true)) { 
    350             FATAL("Unable to build audio frames"); 
    351             return false; 
    352         } 
    353     } 
    354  
    355     if (pAVCC != NULL) { 
    356         //Build video frames 
    357         if (!BuildFrames(false)) { 
    358             FATAL("Unable to build video frames"); 
    359             return false; 
    360         } 
    361     } 
    362  
    363     //sort the frames 
    364     sort(_frames.begin(), _frames.end(), CompareFrames); 
    365  
    366     //add binary audio header 
    367     MediaFrame audioHeader = {0}; 
    368     if (pESDS != NULL) { 
    369         audioHeader.type = MEDIAFRAME_TYPE_AUDIO; 
    370         audioHeader.isBinaryHeader = true; 
    371         audioHeader.isKeyFrame = true; 
    372         audioHeader.length = pESDS->GetExtraDataLength(); 
    373         audioHeader.absoluteTime = 0; 
    374         audioHeader.start = pESDS->GetExtraDataStart(); 
    375         audioHeader.deltaTime = 0; 
    376         audioHeader.compositionOffset = 0; 
    377         FINEST("Start: %llu (%llx); Length: %llu (%llx);", audioHeader.start, 
    378                 audioHeader.start, audioHeader.length, audioHeader.length); 
    379     } 
    380     //ADD_VECTOR_BEGIN(_frames, audioHeader); 
    381  
    382     //add binary video header 
    383     MediaFrame videoHeader = {0}; 
    384     if (pAVCC != NULL) { 
    385         videoHeader.type = MEDIAFRAME_TYPE_VIDEO; 
    386         videoHeader.isBinaryHeader = true; 
    387         videoHeader.isKeyFrame = true; 
    388         videoHeader.length = pAVCC->GetExtraDataLength(); 
    389         videoHeader.absoluteTime = 0; 
    390         videoHeader.start = pAVCC->GetExtraDataStart(); 
    391         videoHeader.deltaTime = 0; 
    392         videoHeader.compositionOffset = 0; 
    393         //    FINEST("Start: %u (%x); Length: %u (%x);", videoHeader.start, 
    394         //            videoHeader.start, videoHeader.length,videoHeader.length); 
    395         //ADD_VECTOR_BEGIN(_frames, videoHeader); 
    396     } 
    397  
    398     if (pESDS != NULL) { 
    399  
    400         FOR_VECTOR_ITERATOR(MediaFrame, _frames, i) { 
    401             if (VECTOR_VAL(i).type == MEDIAFRAME_TYPE_AUDIO) { 
    402                 _frames.insert(i, audioHeader); 
    403                 break; 
    404             } 
    405         } 
    406     } else { 
    407         WARN("No sound track found"); 
    408     } 
    409  
    410     if (pAVCC != NULL) { 
    411  
    412         FOR_VECTOR_ITERATOR(MediaFrame, _frames, i) { 
    413             if (VECTOR_VAL(i).type == MEDIAFRAME_TYPE_VIDEO) { 
    414                 _frames.insert(i, videoHeader); 
    415                 break; 
    416             } 
    417         } 
    418     } else { 
    419         WARN("No video track found"); 
    420     } 
    421  
    422     return true; 
     330        _frames.clear(); 
     331 
     332        AtomTRAK *pTrack; 
     333        AtomAVCC *pAVCC = NULL; 
     334        if ((pTrack = GetTRAK(false)) != NULL) { 
     335                pAVCC = (AtomAVCC *) pTrack->GetPath(6, A_MDIA, A_MINF, 
     336                                A_STBL, A_STSD, A_AVC1, A_AVCC); 
     337        } 
     338 
     339        AtomESDS *pESDS = NULL; 
     340        if ((pTrack = GetTRAK(true)) != NULL) { 
     341                pESDS = (AtomESDS *) pTrack->GetPath(6, A_MDIA, A_MINF, 
     342                                A_STBL, A_STSD, A_MP4A, A_ESDS); 
     343                if (pESDS == NULL) { 
     344                        pESDS = (AtomESDS *) pTrack->GetPath(7, A_MDIA, A_MINF, 
     345                                        A_STBL, A_STSD, A_MP4A, A_WAVE, A_ESDS); 
     346                } 
     347        } 
     348 
     349        if (pESDS != NULL) { 
     350                //Build audio frames 
     351                if (!BuildFrames(true)) { 
     352                        FATAL("Unable to build audio frames"); 
     353                        return false; 
     354                } 
     355        } 
     356 
     357        if (pAVCC != NULL) { 
     358                //Build video frames 
     359                if (!BuildFrames(false)) { 
     360                        FATAL("Unable to build video frames"); 
     361                        return false; 
     362                } 
     363        } 
     364 
     365        //sort the frames 
     366        sort(_frames.begin(), _frames.end(), CompareFrames); 
     367 
     368        //add binary audio header 
     369        MediaFrame audioHeader = {0}; 
     370        if (pESDS != NULL) { 
     371                audioHeader.type = MEDIAFRAME_TYPE_AUDIO; 
     372                audioHeader.isBinaryHeader = true; 
     373                audioHeader.isKeyFrame = true; 
     374                audioHeader.length = pESDS->GetExtraDataLength(); 
     375                audioHeader.absoluteTime = 0; 
     376                audioHeader.start = pESDS->GetExtraDataStart(); 
     377                audioHeader.deltaTime = 0; 
     378                audioHeader.compositionOffset = 0; 
     379                FINEST("Start: %llu (%llx); Length: %llu (%llx);", audioHeader.start, 
     380                                audioHeader.start, audioHeader.length, audioHeader.length); 
     381        } 
     382        //ADD_VECTOR_BEGIN(_frames, audioHeader); 
     383 
     384        //add binary video header 
     385        MediaFrame videoHeader = {0}; 
     386        if (pAVCC != NULL) { 
     387                videoHeader.type = MEDIAFRAME_TYPE_VIDEO; 
     388                videoHeader.isBinaryHeader = true; 
     389                videoHeader.isKeyFrame = true; 
     390                videoHeader.length = pAVCC->GetExtraDataLength(); 
     391                videoHeader.absoluteTime = 0; 
     392                videoHeader.start = pAVCC->GetExtraDataStart(); 
     393                videoHeader.deltaTime = 0; 
     394                videoHeader.compositionOffset = 0; 
     395                //    FINEST("Start: %u (%x); Length: %u (%x);", videoHeader.start, 
     396                //            videoHeader.start, videoHeader.length,videoHeader.length); 
     397                //ADD_VECTOR_BEGIN(_frames, videoHeader); 
     398        } 
     399 
     400        if (pESDS != NULL) { 
     401 
     402                FOR_VECTOR_ITERATOR(MediaFrame, _frames, i) { 
     403                        if (VECTOR_VAL(i).type == MEDIAFRAME_TYPE_AUDIO) { 
     404                                _frames.insert(i, audioHeader); 
     405                                break; 
     406                        } 
     407                } 
     408        } else { 
     409                WARN("No sound track found"); 
     410        } 
     411 
     412        if (pAVCC != NULL) { 
     413 
     414                FOR_VECTOR_ITERATOR(MediaFrame, _frames, i) { 
     415                        if (VECTOR_VAL(i).type == MEDIAFRAME_TYPE_VIDEO) { 
     416                                _frames.insert(i, videoHeader); 
     417                                break; 
     418                        } 
     419                } 
     420        } else { 
     421                WARN("No video track found"); 
     422        } 
     423 
     424        return true; 
    423425} 
    424426 
    425427bool MP4Document::BuildFrames(bool audio) { 
    426     //1. Get the track 
    427     AtomTRAK *pTrack = GetTRAK(audio); 
    428     if (pTrack == NULL) { 
    429         FATAL("no %s track", audio ? "Audio" : "Video"); 
    430         return false; 
    431     } 
    432  
    433     //2. Get the atom containing sample sizes 
    434     AtomSTSZ *pSTSZ = (AtomSTSZ *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
    435             A_STSZ); 
    436     if (pSTSZ == NULL) { 
    437         FATAL("no STSZ"); 
    438         return false; 
    439     } 
    440  
    441     //3. Get the atom containing the chuncks offests 
    442     AtomCO64 *pCO64 = NULL; 
    443     AtomSTCO *pSTCO = (AtomSTCO *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
    444             A_STCO); 
    445     if (pSTCO == NULL) { 
    446         pCO64 = (AtomCO64 *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, A_CO64); 
    447         if (pCO64 == NULL) { 
    448             FATAL("no CO64"); 
    449             return false; 
    450         } 
    451     } 
    452  
    453     //4. Get the atom containing the distribution of samples per corresponding 
    454     //chunks 
    455     AtomSTSC *pSTSC = (AtomSTSC *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
    456             A_STSC); 
    457     if (pSTSC == NULL) { 
    458         FATAL("no STSC"); 
    459         return false; 
    460     } 
    461  
    462     //5. Get the atom containing the delta time of each sample 
    463     AtomSTTS *pSTTS = (AtomSTTS *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
    464             A_STTS); 
    465     if (pSTTS == NULL) { 
    466         FATAL("no STTS"); 
    467         return false; 
    468     } 
    469  
    470     //6. Get the atom containing the time scale of each delta time 
    471     AtomMDHD *pMDHD = (AtomMDHD *) pTrack->GetPath(2, A_MDIA, A_MDHD); 
    472     if (pMDHD == NULL) { 
    473         FATAL("no MDHD"); 
    474         return false; 
    475     } 
    476  
    477     //7. Get the table containing the samples marked as key frames. It can be null 
    478     //It can be null 
    479     AtomSTSS *pSTSS = (AtomSTSS *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
    480             A_STSS); 
    481  
    482     //8. Get the composition timestamps 
    483     AtomCTTS *pCTSS = (AtomCTTS *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
    484             A_CTTS); 
    485  
    486     //8. Extract normalized information from the atoms retrived above 
    487     vector<uint64_t> sampleSize = pSTSZ->GetEntries(); 
    488     if (audio) 
    489         _audioSamplesCount = sampleSize.size(); 
    490     else 
    491         _videoSamplesCount = sampleSize.size(); 
    492     vector<uint32_t> sampleDeltaTime = pSTTS->GetEntries(); 
    493     vector<uint64_t> chunckOffsets; 
    494     if (pSTCO != NULL) 
    495         chunckOffsets = pSTCO->GetEntries(); 
    496     else 
    497         chunckOffsets = pCO64->GetEntries(); 
    498     vector<uint32_t> sample2Chunk = pSTSC->GetEntries(chunckOffsets.size()); 
    499     vector<uint32_t> keyFrames; 
    500     if (pSTSS != NULL) 
    501         keyFrames = pSTSS->GetEntries(); 
    502     vector<int32_t> compositionOffsets; 
    503     if (pCTSS != NULL) { 
    504         compositionOffsets = pCTSS->GetEntries(); 
    505         if (sampleSize.size() != compositionOffsets.size()) { 
    506             WARN("composition offsets count != samples count; compositionOffsets: %d; sampleSize.size: %d", 
    507                     compositionOffsets.size(), 
    508                     sampleSize.size()); 
    509             for (uint32_t i = compositionOffsets.size(); i < sampleSize.size(); i++) 
    510                 ADD_VECTOR_END(compositionOffsets, 0); 
    511             WARN("composition offsets padded with 0. Now size is %d", 
    512                     compositionOffsets.size()); 
    513         } 
    514     } 
    515     INFO("audio: %d; keyFrames: %u; frames: %u; compositionOffsets: %u", 
    516             audio, keyFrames.size(), sampleSize.size(), compositionOffsets.size()); 
    517  
    518     //    FINEST("sampleSize count: %d", sampleSize.size()); 
    519     //    FINEST("sampleDeltaTime count: %d", sampleDeltaTime.size()); 
    520     //    FINEST("chunckOffsets count: %d", chunckOffsets.size()); 
    521     //    FINEST("sample2Chunk count: %d", sample2Chunk.size()); 
    522     //    FINEST("keyFrames count: %d", keyFrames.size()); 
    523  
    524     uint32_t timeScale = pMDHD->GetTimeScale(); 
    525     uint32_t totalTime = 0; 
    526     uint32_t localOffset = 0; 
    527     uint32_t startIndex = _frames.size(); 
    528  
    529     for (uint32_t i = 0; i < sampleSize.size(); i++) { 
    530         MediaFrame frame = {0}; 
    531         frame.start = chunckOffsets[sample2Chunk[i]] + localOffset; 
    532         if (pCTSS != NULL) { 
    533             double doubleVal = ((double) compositionOffsets[i] / (double) timeScale)*(double) 1000.00; 
    534             frame.compositionOffset = (int32_t) doubleVal; 
    535             //FINEST("frame.compositionOffset: %08x", frame.compositionOffset); 
    536         } else { 
    537             frame.compositionOffset = 0; 
    538         } 
    539         if (i <= sampleSize.size() - 2) { 
    540             //not the last frame 
    541             uint32_t currentChunck = sample2Chunk[i]; 
    542             uint32_t nextChunck = sample2Chunk[i + 1]; 
    543  
    544  
    545             if (currentChunck == nextChunck) { 
    546                 //not changing the chunk 
    547                 localOffset += sampleSize[i]; 
    548             } else { 
    549                 //changing the chunck 
    550                 localOffset = 0; 
    551             } 
    552  
    553         } else { 
    554             // we are near end, so we are on the same chunck 
    555             localOffset += sampleSize[i]; 
    556         } 
    557  
    558         frame.length = sampleSize[i]; 
    559         frame.type = audio ? MEDIAFRAME_TYPE_AUDIO : MEDIAFRAME_TYPE_VIDEO; 
    560         if (pSTSS == NULL) { 
    561             //no kayframe info. All frames are considered key frames 
    562             frame.isKeyFrame = true; 
    563         } else { 
    564             //default it to false, will set it later 
    565             frame.isKeyFrame = false; 
    566         } 
    567         //frame.isKeyFrame = true; 
    568         frame.deltaTime = ((double) sampleDeltaTime[i] / (double) timeScale)*(double) 1000.00; 
    569         frame.absoluteTime = ((double) totalTime / (double) timeScale)*(double) 1000.00; 
    570         frame.isBinaryHeader = false; 
    571         totalTime += sampleDeltaTime[i]; 
    572  
    573         //FINEST("Frame: %s", STR(frame)); 
    574         ADD_VECTOR_END(_frames, frame); 
    575     } 
    576  
    577     FOR_VECTOR(keyFrames, i) { 
    578         _frames[startIndex + keyFrames[i] - 1].isKeyFrame = true; 
    579     } 
    580  
    581     return true; 
     428        //1. Get the track 
     429        AtomTRAK *pTrack = GetTRAK(audio); 
     430        if (pTrack == NULL) { 
     431                FATAL("no %s track", audio ? "Audio" : "Video"); 
     432                return false; 
     433        } 
     434 
     435        //2. Get the atom containing sample sizes 
     436        AtomSTSZ *pSTSZ = (AtomSTSZ *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
     437                        A_STSZ); 
     438        if (pSTSZ == NULL) { 
     439                FATAL("no STSZ"); 
     440                return false; 
     441        } 
     442 
     443        //3. Get the atom containing the chuncks offests 
     444        AtomCO64 *pCO64 = NULL; 
     445        AtomSTCO *pSTCO = (AtomSTCO *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
     446                        A_STCO); 
     447        if (pSTCO == NULL) { 
     448                pCO64 = (AtomCO64 *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, A_CO64); 
     449                if (pCO64 == NULL) { 
     450                        FATAL("no CO64"); 
     451                        return false; 
     452                } 
     453        } 
     454 
     455        //4. Get the atom containing the distribution of samples per corresponding 
     456        //chunks 
     457        AtomSTSC *pSTSC = (AtomSTSC *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
     458                        A_STSC); 
     459        if (pSTSC == NULL) { 
     460                FATAL("no STSC"); 
     461                return false; 
     462        } 
     463 
     464        //5. Get the atom containing the delta time of each sample 
     465        AtomSTTS *pSTTS = (AtomSTTS *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
     466                        A_STTS); 
     467        if (pSTTS == NULL) { 
     468                FATAL("no STTS"); 
     469                return false; 
     470        } 
     471 
     472        //6. Get the atom containing the time scale of each delta time 
     473        AtomMDHD *pMDHD = (AtomMDHD *) pTrack->GetPath(2, A_MDIA, A_MDHD); 
     474        if (pMDHD == NULL) { 
     475                FATAL("no MDHD"); 
     476                return false; 
     477        } 
     478 
     479        //7. Get the table containing the samples marked as key frames. It can be null 
     480        //It can be null 
     481        AtomSTSS *pSTSS = (AtomSTSS *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
     482                        A_STSS); 
     483 
     484        //8. Get the composition timestamps 
     485        AtomCTTS *pCTSS = (AtomCTTS *) pTrack->GetPath(4, A_MDIA, A_MINF, A_STBL, 
     486                        A_CTTS); 
     487 
     488        //8. Extract normalized information from the atoms retrived above 
     489        vector<uint64_t> sampleSize = pSTSZ->GetEntries(); 
     490        if (audio) 
     491                _audioSamplesCount = sampleSize.size(); 
     492        else 
     493                _videoSamplesCount = sampleSize.size(); 
     494        vector<uint32_t> sampleDeltaTime = pSTTS->GetEntries(); 
     495        vector<uint64_t> chunckOffsets; 
     496        if (pSTCO != NULL) 
     497                chunckOffsets = pSTCO->GetEntries(); 
     498        else 
     499                chunckOffsets = pCO64->GetEntries(); 
     500        vector<uint32_t> sample2Chunk = pSTSC->GetEntries(chunckOffsets.size()); 
     501        vector<uint32_t> keyFrames; 
     502        if (pSTSS != NULL) 
     503                keyFrames = pSTSS->GetEntries(); 
     504        vector<int32_t> compositionOffsets; 
     505        if (pCTSS != NULL) { 
     506                compositionOffsets = pCTSS->GetEntries(); 
     507                if (sampleSize.size() != compositionOffsets.size()) { 
     508                        WARN("composition offsets count != samples count; compositionOffsets: %d; sampleSize.size: %d", 
     509                                        compositionOffsets.size(), 
     510                                        sampleSize.size()); 
     511                        for (uint32_t i = compositionOffsets.size(); i < sampleSize.size(); i++) 
     512                                ADD_VECTOR_END(compositionOffsets, 0); 
     513                        WARN("composition offsets padded with 0. Now size is %d", 
     514                                        compositionOffsets.size()); 
     515                } 
     516        } 
     517        INFO("audio: %d; keyFrames: %u; frames: %u; compositionOffsets: %u", 
     518                        audio, keyFrames.size(), sampleSize.size(), compositionOffsets.size()); 
     519 
     520        //    FINEST("sampleSize count: %d", sampleSize.size()); 
     521        //    FINEST("sampleDeltaTime count: %d", sampleDeltaTime.size()); 
     522        //    FINEST("chunckOffsets count: %d", chunckOffsets.size()); 
     523        //    FINEST("sample2Chunk count: %d", sample2Chunk.size()); 
     524        //    FINEST("keyFrames count: %d", keyFrames.size()); 
     525 
     526        uint32_t timeScale = pMDHD->GetTimeScale(); 
     527        uint32_t totalTime = 0; 
     528        uint32_t localOffset = 0; 
     529        uint32_t startIndex = _frames.size(); 
     530 
     531        for (uint32_t i = 0; i < sampleSize.size(); i++) { 
     532                MediaFrame frame = {0}; 
     533                frame.start = chunckOffsets[sample2Chunk[i]] + localOffset; 
     534                if (pCTSS != NULL) { 
     535                        double doubleVal = ((double) compositionOffsets[i] / (double) timeScale)*(double) 1000.00; 
     536                        frame.compositionOffset = (int32_t) doubleVal; 
     537                        //FINEST("frame.compositionOffset: %08x", frame.compositionOffset); 
     538                } else { 
     539                        frame.compositionOffset = 0; 
     540                } 
     541                if (i <= sampleSize.size() - 2) { 
     542                        //not the last frame 
     543                        uint32_t currentChunck = sample2Chunk[i]; 
     544                        uint32_t nextChunck = sample2Chunk[i + 1]; 
     545 
     546 
     547                        if (currentChunck == nextChunck) { 
     548                                //not changing the chunk 
     549                                localOffset += sampleSize[i]; 
     550                        } else { 
     551                                //changing the chunck 
     552                                localOffset = 0; 
     553                        } 
     554 
     555                } else { 
     556                        // we are near end, so we are on the same chunck 
     557                        localOffset += sampleSize[i]; 
     558                } 
     559 
     560                frame.length = sampleSize[i]; 
     561                frame.type = audio ? MEDIAFRAME_TYPE_AUDIO : MEDIAFRAME_TYPE_VIDEO; 
     562                if (pSTSS == NULL) { 
     563                        //no kayframe info. All frames are considered key frames 
     564                        frame.isKeyFrame = true; 
     565                } else { 
     566                        //default it to false, will set it later 
     567                        frame.isKeyFrame = false; 
     568                } 
     569                //frame.isKeyFrame = true; 
     570                frame.deltaTime = ((double) sampleDeltaTime[i] / (double) timeScale)*(double) 1000.00; 
     571                frame.absoluteTime = ((double) totalTime / (double) timeScale)*(double) 1000.00; 
     572                frame.isBinaryHeader = false; 
     573                totalTime += sampleDeltaTime[i]; 
     574 
     575                //FINEST("Frame: %s", STR(frame)); 
     576                ADD_VECTOR_END(_frames, frame); 
     577        } 
     578 
     579        FOR_VECTOR(keyFrames, i) { 
     580                _frames[startIndex + keyFrames[i] - 1].isKeyFrame = true; 
     581        } 
     582 
     583        return true; 
    582584} 
    583585 
    584586Variant MP4Document::GetRTMPMeta() { 
    585     Variant result; 
    586  
    587     AtomTRAK *pVideoTrack = GetTRAK(false); 
    588     if (pVideoTrack != NULL) { 
    589         AtomTKHD *pTKHD = (AtomTKHD *) pVideoTrack->GetPath(1, A_TKHD); 
    590         if (pTKHD != NULL) { 
    591             result["width"] = pTKHD->GetWidth(); 
    592             result["height"] = pTKHD->GetHeight(); 
    593         } 
    594     } 
    595  
    596     if (_pMOOV != NULL) { 
    597         AtomILST *pILST = (AtomILST *) _pMOOV->GetPath(3, A_UDTA, A_META, A_ILST); 
    598  
    599         if (pILST != NULL) { 
    600             result["tags"] = pILST->GetVariant(); 
    601         } else { 
    602             WARN("No ilst atom present"); 
    603         } 
    604     } 
    605  
    606     return result; 
     587        Variant result; 
     588 
     589        AtomTRAK *pVideoTrack = GetTRAK(false); 
     590        if (pVideoTrack != NULL) { 
     591                AtomTKHD *pTKHD = (AtomTKHD *) pVideoTrack->GetPath(1, A_TKHD); 
     592                if (pTKHD != NULL) { 
     593                        result["width"] = pTKHD->GetWidth(); 
     594                        result["height"] = pTKHD->GetHeight(); 
     595                } 
     596        } 
     597 
     598        if (_pMOOV != NULL) { 
     599                AtomILST *pILST = (AtomILST *) _pMOOV->GetPath(3, A_UDTA, A_META, A_ILST); 
     600 
     601                if (pILST != NULL) { 
     602                        result["tags"] = pILST->GetVariant(); 
     603                } else { 
     604                        WARN("No ilst atom present"); 
     605                } 
     606        } 
     607 
     608        return result; 
    607609} 
    608610 
    609611string MP4Document::Hierarchy() { 
    610     string result = ""; 
    611     for (uint32_t i = 0; i < _topAtoms.size(); i++) { 
    612         result += _topAtoms[i]->Hierarchy(1); 
    613         if (i != _topAtoms.size() - 1) 
    614             result += "\n"; 
    615     } 
    616     return result; 
     612        string result = ""; 
     613        for (uint32_t i = 0; i < _topAtoms.size(); i++) { 
     614                result += _topAtoms[i]->Hierarchy(1); 
     615                if (i != _topAtoms.size() - 1) 
     616                        result += "\n"; 
     617        } 
     618        return result; 
    617619} 
    618620 
    619621AtomTRAK * MP4Document::GetTRAK(bool audio) { 
    620     if (_pMOOV == NULL) { 
    621         FATAL("Unable to find moov"); 
    622         return false; 
    623     } 
    624     vector<AtomTRAK *> tracks = _pMOOV->GetTracks(); 
    625     if (tracks.size() == 0) { 
    626         FATAL("No tracks defined"); 
    627         return false; 
    628     } 
    629     for (uint32_t i = 0; i < tracks.size(); i++) { 
    630         AtomHDLR *pHDLR = (AtomHDLR *) tracks[i]->GetPath(2, A_MDIA, A_HDLR); 
    631         if (audio && (pHDLR->GetComponentSubType() == A_SOUN)) 
    632             return tracks[i]; 
    633         if ((!audio) && (pHDLR->GetComponentSubType() == A_VIDE)) 
    634             return tracks[i]; 
    635     } 
    636     return NULL; 
    637 } 
    638  
    639  
     622        if (_pMOOV == NULL) { 
     623                FATAL("Unable to find moov"); 
     624                return false; 
     625        } 
     626        vector<AtomTRAK *> tracks = _pMOOV->GetTracks(); 
     627        if (tracks.size() == 0) { 
     628                FATAL("No tracks defined"); 
     629                return false; 
     630        } 
     631        for (uint32_t i = 0; i < tracks.size(); i++) { 
     632                AtomHDLR *pHDLR = (AtomHDLR *) tracks[i]->GetPath(2, A_MDIA, A_HDLR); 
     633                if (audio && (pHDLR->GetComponentSubType() == A_SOUN)) 
     634                        return tracks[i]; 
     635                if ((!audio) && (pHDLR->GetComponentSubType() == A_VIDE)) 
     636                        return tracks[i]; 
     637        } 
     638        return NULL; 
     639} 
     640 
     641 
     642#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/versionedatom.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/versionedatom.h" 
    2222 
    2323VersionedAtom::VersionedAtom(MP4Document *pDocument, uint32_t type, 
    24         uint64_t size, uint64_t start) 
     24                uint64_t size, uint64_t start) 
    2525: BaseAtom(pDocument, type, size, start) { 
    26     _version = 0; 
    27     memset(_flags, 0, 3); 
     26        _version = 0; 
     27        memset(_flags, 0, 3); 
    2828} 
    2929 
     
    3232 
    3333bool VersionedAtom::Read() { 
    34     if (!ReadUInt8(_version)) { 
    35         FATAL("Unable to read version"); 
    36         return false; 
    37     } 
    38     //FINEST("_version: %d", _version); 
     34        if (!ReadUInt8(_version)) { 
     35                FATAL("Unable to read version"); 
     36                return false; 
     37        } 
     38        //FINEST("_version: %d", _version); 
    3939 
    40     if (!ReadArray(_flags, 3)) { 
    41         FATAL("Unable to read flags"); 
    42         return false; 
    43     } 
    44     //FINEST("_flags: %02x %02x %02x", _flags[0], _flags[1], _flags[2]); 
     40        if (!ReadArray(_flags, 3)) { 
     41                FATAL("Unable to read flags"); 
     42                return false; 
     43        } 
     44        //FINEST("_flags: %02x %02x %02x", _flags[0], _flags[1], _flags[2]); 
    4545 
    46     return ReadData(); 
     46        return ReadData(); 
    4747} 
    4848 
    4949string VersionedAtom::Hierarchy(uint32_t indent) { 
    50     return string(4 * indent, ' ') + GetTypeString(); 
     50        return string(4 * indent, ' ') + GetTypeString(); 
    5151} 
    5252 
     53#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/mediaformats/mp4/versionedboxatom.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    20  
     20#ifdef HAS_MEDIA_MP4 
    2121#include "mediaformats/mp4/versionedboxatom.h" 
    2222 
    2323VersionedBoxAtom::VersionedBoxAtom(MP4Document *pDocument, uint32_t type, 
    24         uint64_t size, uint64_t start) 
     24                uint64_t size, uint64_t start) 
    2525: BoxAtom(pDocument, type, size, start) { 
    26     _version = 0; 
    27     memset(_flags, 0, 3); 
     26        _version = 0; 
     27        memset(_flags, 0, 3); 
    2828} 
    2929 
     
    3232 
    3333bool VersionedBoxAtom::Read() { 
    34     if (!ReadUInt8(_version)) { 
    35         FATAL("Unable to read version"); 
    36         return false; 
    37     } 
    38     //FINEST("_version: %d", _version); 
     34        if (!ReadUInt8(_version)) { 
     35                FATAL("Unable to read version"); 
     36                return false; 
     37        } 
     38        //FINEST("_version: %d", _version); 
    3939 
    40     if (!ReadArray(_flags, 3)) { 
    41         FATAL("Unable to read flags"); 
    42         return false; 
    43     } 
    44     //FINEST("_flags: %02x %02x %02x", _flags[0], _flags[1], _flags[2]); 
     40        if (!ReadArray(_flags, 3)) { 
     41                FATAL("Unable to read flags"); 
     42                return false; 
     43        } 
     44        //FINEST("_flags: %02x %02x %02x", _flags[0], _flags[1], _flags[2]); 
    4545 
    46     if (!ReadData()) { 
    47         FATAL("Unable to read data"); 
    48         return false; 
    49     } 
     46        if (!ReadData()) { 
     47                FATAL("Unable to read data"); 
     48                return false; 
     49        } 
    5050 
    51     return BoxAtom::Read(); 
     51        return BoxAtom::Read(); 
    5252} 
    5353 
    5454 
     55#endif /* HAS_MEDIA_MP4 */ 
  • trunk/sources/thelib/src/streaming/baseinfilestream.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    3434 
    3535BaseInFileStream::InFileStreamTimer::InFileStreamTimer(BaseInFileStream *pInFileStream) { 
    36     _pInFileStream = pInFileStream; 
     36        _pInFileStream = pInFileStream; 
    3737} 
    3838 
     
    4242 
    4343void BaseInFileStream::InFileStreamTimer::ResetStream() { 
    44     _pInFileStream = NULL; 
     44        _pInFileStream = NULL; 
    4545} 
    4646 
    4747bool BaseInFileStream::InFileStreamTimer::TimePeriodElapsed() { 
    48     if (_pInFileStream != NULL) 
    49         _pInFileStream->ReadyForSend(); 
    50     return true; 
     48        if (_pInFileStream != NULL) 
     49                _pInFileStream->ReadyForSend(); 
     50        return true; 
    5151} 
    5252 
    5353BaseInFileStream::BaseInFileStream(BaseProtocol *pProtocol, 
    54         StreamsManager *pStreamsManager, uint64_t type, string name) 
     54                StreamsManager *pStreamsManager, uint64_t type, string name) 
    5555: BaseInStream(pProtocol, pStreamsManager, type, name) { 
    56     if (!TAG_KIND_OF(type, ST_IN_FILE)) { 
    57         ASSERT("Incorrect stream type. Wanted a stream type in class %s and got %s", 
    58                 STR(tagToString(ST_IN_FILE)), STR(tagToString(type))); 
    59     } 
    60     _pTimer = NULL; 
    61     _pSeekFile = NULL; 
    62     _pFile = NULL; 
    63  
    64     //frame info 
    65     _totalFrames = 0; 
    66     _currentFrameIndex = 0; 
    67     memset(&_currentFrame, 0, sizeof (MediaFrame)); 
    68  
    69     //timing info 
    70     _totalSentTime = 0; 
    71     _totalSentTimeBase = 0; 
    72     _startFeedingTime = 0; 
    73  
    74     //buffering info 
    75     _clientSideBufferLength = 0; 
    76  
    77     //current state info 
    78     _paused = true; 
     56        if (!TAG_KIND_OF(type, ST_IN_FILE)) { 
     57                ASSERT("Incorrect stream type. Wanted a stream type in class %s and got %s", 
     58                                STR(tagToString(ST_IN_FILE)), STR(tagToString(type))); 
     59        } 
     60        _pTimer = NULL; 
     61        _pSeekFile = NULL; 
     62        _pFile = NULL; 
     63 
     64        //frame info 
     65        _totalFrames = 0; 
     66        _currentFrameIndex = 0; 
     67        memset(&_currentFrame, 0, sizeof (MediaFrame)); 
     68 
     69        //timing info 
     70        _totalSentTime = 0; 
     71        _totalSentTimeBase = 0; 
     72        _startFeedingTime = 0; 
     73 
     74        //buffering info 
     75        _clientSideBufferLength = 0; 
     76 
     77        //current state info 
     78        _paused = true; 
    7979} 
    8080 
    8181BaseInFileStream::~BaseInFileStream() { 
    82     if (_pTimer != NULL) { 
    83         _pTimer->ResetStream(); 
    84         _pTimer->EnqueueForDelete(); 
    85         _pTimer = NULL; 
    86     } 
    87     ReleaseFile(_pSeekFile); 
    88     ReleaseFile(_pFile); 
     82        if (_pTimer != NULL) { 
     83                _pTimer->ResetStream(); 
     84                _pTimer->EnqueueForDelete(); 
     85                _pTimer = NULL; 
     86        } 
     87        ReleaseFile(_pSeekFile); 
     88        ReleaseFile(_pFile); 
    8989} 
    9090 
    9191StreamCapabilities * BaseInFileStream::GetCapabilities() { 
    92     NYI; 
    93     return NULL; 
     92        NYI; 
     93        return NULL; 
    9494} 
    9595 
    9696bool BaseInFileStream::ResolveCompleteMetadata(Variant &metaData) { 
    97     //1. Create the document 
    98     BaseMediaDocument *pDocument = NULL; 
    99     if (metaData[META_MEDIA_TYPE] == MEDIA_TYPE_FLV || 
    100             metaData[META_MEDIA_TYPE] == MEDIA_TYPE_LIVE_OR_FLV) { 
    101         pDocument = new FLVDocument(metaData); 
    102     } else if (metaData[META_MEDIA_TYPE] == MEDIA_TYPE_MP3) { 
    103         pDocument = new MP3Document(metaData); 
    104     } else if (metaData[META_MEDIA_TYPE] == MEDIA_TYPE_MP4 
    105             || metaData[META_MEDIA_TYPE] == MEDIA_TYPE_M4A 
    106             || metaData[META_MEDIA_TYPE] == MEDIA_TYPE_M4V 
    107             || metaData[META_MEDIA_TYPE] == MEDIA_TYPE_MOV 
    108             || metaData[META_MEDIA_TYPE] == MEDIA_TYPE_F4V) { 
    109         pDocument = new MP4Document(metaData); 
    110     } else { 
    111         FATAL("File type not supported yet. Partial metadata:\n%s", 
    112                 STR(metaData.ToString())); 
    113         return false; 
    114     } 
    115  
    116     //2. Process the document 
    117     if (!pDocument->Process()) { 
    118         FATAL("Unable to process document"); 
    119         delete pDocument; 
    120         MoveFile(metaData[META_SERVER_FULL_PATH], 
    121                 (string) metaData[META_SERVER_FULL_PATH] + ".bad"); 
    122         return false; 
    123     } 
    124  
    125     //3. Get the medatada 
    126     metaData = pDocument->GetMetadata(); 
    127  
    128     //4. cleanup 
    129     delete pDocument; 
    130  
    131     //5. Done 
    132     return true; 
     97        //1. Create the document 
     98        BaseMediaDocument *pDocument = NULL; 
     99        if (false) { 
     100 
     101        } 
     102#ifdef HAS_MEDIA_FLV 
     103        else if (metaData[META_MEDIA_TYPE] == MEDIA_TYPE_FLV || 
     104                        metaData[META_MEDIA_TYPE] == MEDIA_TYPE_LIVE_OR_FLV) { 
     105                pDocument = new FLVDocument(metaData); 
     106        } 
     107#endif /* HAS_MEDIA_FLV */ 
     108#ifdef HAS_MEDIA_MP3 
     109        else if (metaData[META_MEDIA_TYPE] == MEDIA_TYPE_MP3) { 
     110                pDocument = new MP3Document(metaData); 
     111        } 
     112#endif /* HAS_MEDIA_MP3 */ 
     113#ifdef HAS_MEDIA_MP4 
     114        else if (metaData[META_MEDIA_TYPE] == MEDIA_TYPE_MP4 
     115                        || metaData[META_MEDIA_TYPE] == MEDIA_TYPE_M4A 
     116                        || metaData[META_MEDIA_TYPE] == MEDIA_TYPE_M4V 
     117                        || metaData[META_MEDIA_TYPE] == MEDIA_TYPE_MOV 
     118                        || metaData[META_MEDIA_TYPE] == MEDIA_TYPE_F4V) { 
     119                pDocument = new MP4Document(metaData); 
     120        } 
     121#endif /* HAS_MEDIA_MP4 */ 
     122        else { 
     123                FATAL("File type not supported yet. Partial metadata:\n%s", 
     124                                STR(metaData.ToString())); 
     125                return false; 
     126        } 
     127 
     128        //2. Process the document 
     129        if (!pDocument->Process()) { 
     130                FATAL("Unable to process document"); 
     131                delete pDocument; 
     132                MoveFile(metaData[META_SERVER_FULL_PATH], 
     133                                (string) metaData[META_SERVER_FULL_PATH] + ".bad"); 
     134                return false; 
     135        } 
     136 
     137        //3. Get the medatada 
     138        metaData = pDocument->GetMetadata(); 
     139 
     140        //4. cleanup 
     141        delete pDocument; 
     142 
     143        //5. Done 
     144        return true; 
    133145} 
    134146 
    135147bool BaseInFileStream::Initialize(int32_t clientSideBufferLength) { 
    136     //1. Check to see if we have an universal seeking file 
    137     string seekFilePath = GetName() + "."MEDIA_TYPE_SEEK; 
    138     if (!fileExists(seekFilePath)) { 
    139         Variant temp; 
    140         temp[META_SERVER_FULL_PATH] = GetName(); 
    141         if (!ResolveCompleteMetadata(temp)) { 
    142             FATAL("Unable to generate metadata"); 
    143             return false; 
    144         } 
    145     } 
    146  
    147     //2. Open the seek file 
    148     _pSeekFile = GetFile(seekFilePath, 128 * 1024); 
    149     if (_pSeekFile == NULL) { 
    150         FATAL("Unable to open seeking file %s", STR(seekFilePath)); 
    151         return false; 
    152     } 
    153  
    154     //3. Compute the optimal window size by reading the biggest frame size 
    155     //from the seek file. 
    156     if (!_pSeekFile->SeekTo(_pSeekFile->Size() - 8)) { 
    157         FATAL("Unable to seek to %lld position", _pSeekFile->Cursor() - 8); 
    158         return false; 
    159     } 
    160     uint64_t maxFrameSize = 0; 
    161     if (!_pSeekFile->ReadUI64(&maxFrameSize, false)) { 
    162         FATAL("Unable to read max frame size"); 
    163         return false; 
    164     } 
    165     if (!_pSeekFile->SeekBegin()) { 
    166         FATAL("Unable to seek to beginning of the file"); 
    167         return false; 
    168     } 
    169  
    170     //3. Open the media file 
    171     uint32_t windowSize = maxFrameSize * 16; 
    172     windowSize = windowSize < 65536 ? 65536 : windowSize; 
    173     windowSize = (windowSize > (1024 * 1024)) ? (windowSize / 2) : windowSize; 
    174     _pFile = GetFile(GetName(), windowSize); 
    175     if (_pFile == NULL) { 
    176         FATAL("Unable to initialize file"); 
    177         return false; 
    178     } 
    179  
    180     //4. Read the frames count from the file 
    181     _pSeekFile->SeekBegin(); 
    182     if (!_pSeekFile->ReadUI32(&_totalFrames, false)) { 
    183         FATAL("Unable to read the frames count"); 
    184         return false; 
    185     } 
    186     //FINEST("_totalFrames: %u", _totalFrames); 
    187  
    188     //5. Set the client side buffer length 
    189     _clientSideBufferLength = clientSideBufferLength; 
    190  
    191     //6. Create the timer 
    192     _pTimer = new InFileStreamTimer(this); 
    193     _pTimer->EnqueueForTimeEvent(_clientSideBufferLength - _clientSideBufferLength / 3); 
    194  
    195     //7. Done 
    196     return true; 
     148        //1. Check to see if we have an universal seeking file 
     149        string seekFilePath = GetName() + "."MEDIA_TYPE_SEEK; 
     150        if (!fileExists(seekFilePath)) { 
     151                Variant temp; 
     152                temp[META_SERVER_FULL_PATH] = GetName(); 
     153                if (!ResolveCompleteMetadata(temp)) { 
     154                        FATAL("Unable to generate metadata"); 
     155                        return false; 
     156                } 
     157        } 
     158 
     159        //2. Open the seek file 
     160        _pSeekFile = GetFile(seekFilePath, 128 * 1024); 
     161        if (_pSeekFile == NULL) { 
     162                FATAL("Unable to open seeking file %s", STR(seekFilePath)); 
     163                return false; 
     164        } 
     165 
     166        //3. Compute the optimal window size by reading the biggest frame size 
     167        //from the seek file. 
     168        if (!_pSeekFile->SeekTo(_pSeekFile->Size() - 8)) { 
     169                FATAL("Unable to seek to %lld position", _pSeekFile->Cursor() - 8); 
     170                return false; 
     171        } 
     172        uint64_t maxFrameSize = 0; 
     173        if (!_pSeekFile->ReadUI64(&maxFrameSize, false)) { 
     174                FATAL("Unable to read max frame size"); 
     175                return false; 
     176        } 
     177        if (!_pSeekFile->SeekBegin()) { 
     178                FATAL("Unable to seek to beginning of the file"); 
     179                return false; 
     180        } 
     181 
     182        //3. Open the media file 
     183        uint32_t windowSize = maxFrameSize * 16; 
     184        windowSize = windowSize < 65536 ? 65536 : windowSize; 
     185        windowSize = (windowSize > (1024 * 1024)) ? (windowSize / 2) : windowSize; 
     186        _pFile = GetFile(GetName(), windowSize); 
     187        if (_pFile == NULL) { 
     188                FATAL("Unable to initialize file"); 
     189                return false; 
     190        } 
     191 
     192        //4. Read the frames count from the file 
     193        _pSeekFile->SeekBegin(); 
     194        if (!_pSeekFile->ReadUI32(&_totalFrames, false)) { 
     195                FATAL("Unable to read the frames count"); 
     196                return false; 
     197        } 
     198        //FINEST("_totalFrames: %u", _totalFrames); 
     199 
     200        //5. Set the client side buffer length 
     201        _clientSideBufferLength = clientSideBufferLength; 
     202 
     203        //6. Create the timer 
     204        _pTimer = new InFileStreamTimer(this); 
     205        _pTimer->EnqueueForTimeEvent(_clientSideBufferLength - _clientSideBufferLength / 3); 
     206 
     207        //7. Done 
     208        return true; 
    197209} 
    198210 
    199211bool BaseInFileStream::SignalPlay(double &absoluteTimestamp, double &length) { 
    200     //0. fix absoluteTimestamp and length 
    201     absoluteTimestamp = absoluteTimestamp < 0 ? 0 : absoluteTimestamp; 
    202     //TODO: implement the limit playback 
    203     //length = length < 0 ? _totalDuration : length; 
    204  
    205     //1. Seek to the correct point 
    206     if (!InternalSeek(absoluteTimestamp)) { 
    207         FATAL("Unable to seek to %.02f", absoluteTimestamp); 
    208         return false; 
    209     } 
    210  
    211     //2. Put the stream in active mode 
    212     _paused = false; 
    213  
    214     //3. Start the feed reaction 
    215     ReadyForSend(); 
    216  
    217     //4. Done 
    218     return true; 
     212        //0. fix absoluteTimestamp and length 
     213        absoluteTimestamp = absoluteTimestamp < 0 ? 0 : absoluteTimestamp; 
     214        //TODO: implement the limit playback 
     215        //length = length < 0 ? _totalDuration : length; 
     216 
     217        //1. Seek to the correct point 
     218        if (!InternalSeek(absoluteTimestamp)) { 
     219                FATAL("Unable to seek to %.02f", absoluteTimestamp); 
     220                return false; 
     221        } 
     222 
     223        //2. Put the stream in active mode 
     224        _paused = false; 
     225 
     226        //3. Start the feed reaction 
     227        ReadyForSend(); 
     228 
     229        //4. Done 
     230        return true; 
    219231} 
    220232 
    221233bool BaseInFileStream::SignalPause() { 
    222     //1. Is this already paused 
    223     if (_paused) 
    224         return true; 
    225  
    226     //2. Put the stream in paused mode 
    227     _paused = true; 
    228  
    229     //3. Done 
    230     return true; 
     234        //1. Is this already paused 
     235        if (_paused) 
     236                return true; 
     237 
     238        //2. Put the stream in paused mode 
     239        _paused = true; 
     240 
     241        //3. Done 
     242        return true; 
    231243} 
    232244 
    233245bool BaseInFileStream::SignalResume() { 
    234     //1. Is this already active 
    235     if (!_paused) 
    236         return true; 
    237  
    238     //2. Put the stream in active mode 
    239     _paused = false; 
    240  
    241     //3. Start the feed reaction 
    242     ReadyForSend(); 
    243  
    244     //5. Done 
    245     return true; 
     246        //1. Is this already active 
     247        if (!_paused) 
     248                return true; 
     249 
     250        //2. Put the stream in active mode 
     251        _paused = false; 
     252 
     253        //3. Start the feed reaction 
     254        ReadyForSend(); 
     255 
     256        //5. Done 
     257        return true; 
    246258} 
    247259 
    248260bool BaseInFileStream::SignalSeek(double &absoluteTimestamp) { 
    249     //1. Seek to the correct point 
    250     if (!InternalSeek(absoluteTimestamp)) { 
    251         FATAL("Unable to seek to %.02f", absoluteTimestamp); 
    252         return false; 
    253     } 
    254  
    255     //2. If the stream is active, re-initiate the feed reaction 
    256     if (!_paused) 
    257         ReadyForSend(); 
    258  
    259     //3. Done 
    260     return true; 
     261        //1. Seek to the correct point 
     262        if (!InternalSeek(absoluteTimestamp)) { 
     263                FATAL("Unable to seek to %.02f", absoluteTimestamp); 
     264                return false; 
     265        } 
     266 
     267        //2. If the stream is active, re-initiate the feed reaction 
     268        if (!_paused) 
     269                ReadyForSend(); 
     270 
     271        //3. Done 
     272        return true; 
    261273} 
    262274 
    263275bool BaseInFileStream::SignalStop() { 
    264     //1. Is this already paused 
    265     if (_paused) 
    266         return true; 
    267  
    268     //2. Put the stream in paused mode 
    269     _paused = true; 
    270  
    271     //3. Done 
    272     return true; 
     276        //1. Is this already paused 
     277        if (_paused) 
     278                return true; 
     279 
     280        //2. Put the stream in paused mode 
     281        _paused = true; 
     282 
     283        //3. Done 
     284        return true; 
    273285} 
    274286 
    275287void BaseInFileStream::ReadyForSend() { 
    276     if (!Feed()) { 
    277         FATAL("Feed failed"); 
    278         if (_pOutStreams != NULL) 
    279             _pOutStreams->info->EnqueueForDelete(); 
    280     } 
     288        if (!Feed()) { 
     289                FATAL("Feed failed"); 
     290                if (_pOutStreams != NULL) 
     291                        _pOutStreams->info->EnqueueForDelete(); 
     292        } 
    281293} 
    282294 
    283295bool BaseInFileStream::InternalSeek(double &absoluteTimestamp) { 
    284     //1. Switch to millisecond->FrameIndex table 
    285     if (!_pSeekFile->SeekTo(4 + _totalFrames * sizeof (MediaFrame))) { 
    286         FATAL("Failed to seek to ms->FrameIndex table"); 
    287         return false; 
    288     } 
    289  
    290     //2. Read the sampling rate 
    291     uint32_t samplingRate; 
    292     if (!_pSeekFile->ReadUI32(&samplingRate, false)) { 
    293         FATAL("Unable to read the frames per second"); 
    294         return false; 
    295     } 
    296  
    297     //3. compute the index in the time2frameindex 
    298     uint32_t tableIndex = (uint32_t) (absoluteTimestamp / samplingRate); 
    299  
    300     //4. Seek to that corresponding index 
    301     _pSeekFile->SeekAhead(tableIndex * 4); 
    302  
    303     //5. Read the frame index 
    304     uint32_t frameIndex; 
    305     if (!_pSeekFile->ReadUI32(&frameIndex, false)) { 
    306         FATAL("Unable to read frame index"); 
    307         return false; 
    308     } 
    309  
    310     //7. Position the seek file to that particular frame 
    311     if (!_pSeekFile->SeekTo(4 + frameIndex * sizeof (MediaFrame))) { 
    312         FATAL("Unablt to seek inside seek file"); 
    313         return false; 
    314     } 
    315  
    316     //8. Read the frame 
    317     if (!_pSeekFile->ReadBuffer((uint8_t *) & _currentFrame, sizeof (MediaFrame))) { 
    318         FATAL("Unable to read frame from seeking file"); 
    319         return false; 
    320     } 
    321  
    322     //9. update the stream counters 
    323     _startFeedingTime = time(NULL); 
    324     _totalSentTime = 0; 
    325     _currentFrameIndex = frameIndex; 
    326     _totalSentTimeBase = (uint32_t) (_currentFrame.absoluteTime / 1000); 
    327     absoluteTimestamp = _currentFrame.absoluteTime; 
    328  
    329     //10. Go back on the frame of interest 
    330     if (!_pSeekFile->SeekTo(4 + frameIndex * sizeof (MediaFrame))) { 
    331         FATAL("Unablt to seek inside seek file"); 
    332         return false; 
    333     } 
    334  
    335     //11. Done 
    336     return true; 
     296        //1. Switch to millisecond->FrameIndex table 
     297        if (!_pSeekFile->SeekTo(4 + _totalFrames * sizeof (MediaFrame))) { 
     298                FATAL("Failed to seek to ms->FrameIndex table"); 
     299                return false; 
     300        } 
     301 
     302        //2. Read the sampling rate 
     303        uint32_t samplingRate; 
     304        if (!_pSeekFile->ReadUI32(&samplingRate, false)) { 
     305                FATAL("Unable to read the frames per second"); 
     306                return false; 
     307        } 
     308 
     309        //3. compute the index in the time2frameindex 
     310        uint32_t tableIndex = (uint32_t) (absoluteTimestamp / samplingRate); 
     311 
     312        //4. Seek to that corresponding index 
     313        _pSeekFile->SeekAhead(tableIndex * 4); 
     314 
     315        //5. Read the frame index 
     316        uint32_t frameIndex; 
     317        if (!_pSeekFile->ReadUI32(&frameIndex, false)) { 
     318                FATAL("Unable to read frame index"); 
     319                return false; 
     320        } 
     321 
     322        //7. Position the seek file to that particular frame 
     323        if (!_pSeekFile->SeekTo(4 + frameIndex * sizeof (MediaFrame))) { 
     324                FATAL("Unablt to seek inside seek file"); 
     325                return false; 
     326        } 
     327 
     328        //8. Read the frame 
     329        if (!_pSeekFile->ReadBuffer((uint8_t *) & _currentFrame, sizeof (MediaFrame))) { 
     330                FATAL("Unable to read frame from seeking file"); 
     331                return false; 
     332        } 
     333 
     334        //9. update the stream counters 
     335        _startFeedingTime = time(NULL); 
     336        _totalSentTime = 0; 
     337        _currentFrameIndex = frameIndex; 
     338        _totalSentTimeBase = (uint32_t) (_currentFrame.absoluteTime / 1000); 
     339        absoluteTimestamp = _currentFrame.absoluteTime; 
     340 
     341        //10. Go back on the frame of interest 
     342        if (!_pSeekFile->SeekTo(4 + frameIndex * sizeof (MediaFrame))) { 
     343                FATAL("Unablt to seek inside seek file"); 
     344                return false; 
     345        } 
     346 
     347        //11. Done 
     348        return true; 
    337349} 
    338350 
    339351bool BaseInFileStream::Feed() { 
    340     //1. Are we in paused state? 
    341     if (_paused) 
    342         return true; 
    343  
    344     //2. Determine if the client has enough data on the buffer and continue 
    345     //or stay put 
    346     uint32_t elapsedTime = (uint32_t) (time(NULL) - _startFeedingTime); 
    347     //    FINEST("tst: %d; et: %d; diff: %d", 
    348     //            _totalSentTime, elapsedTime, 
    349     //            (int32_t) _totalSentTime - (int32_t) elapsedTime); 
    350     if ((int32_t) _totalSentTime - (int32_t) elapsedTime >= _clientSideBufferLength) { 
    351         return true; 
    352     } 
    353  
    354     //3. Test to see if we have sent the last frame 
    355     if (_currentFrameIndex >= _totalFrames) { 
    356         FINEST("Done streaming file"); 
    357         _pOutStreams->info->SignalStreamCompleted(); 
    358         _paused = true; 
    359         return true; 
    360     } 
    361  
    362     //4. Read the current frame from the seeking file 
    363     if (!_pSeekFile->SeekTo(4 + _currentFrameIndex * sizeof (MediaFrame))) { 
    364         FATAL("Unablt to seek inside seek file"); 
    365         return false; 
    366     } 
    367     if (!_pSeekFile->ReadBuffer((uint8_t *) & _currentFrame, sizeof (_currentFrame))) { 
    368         FATAL("Unable to read frame from seeking file"); 
    369         return false; 
    370     } 
    371  
    372     //5. Skip on metadata 
    373     if (_currentFrame.type == MEDIAFRAME_TYPE_DATA) { 
    374         _currentFrameIndex++; 
    375         return Feed(); 
    376     } 
    377  
    378     //6. get our hands on the correct buffer, depending on the frame type: audio or video 
    379     IOBuffer &buffer = _currentFrame.type == MEDIAFRAME_TYPE_AUDIO ? _audioBuffer : _videoBuffer; 
    380  
    381     //7. Build the frame 
    382     if (!BuildFrame(_pFile, _currentFrame, buffer)) { 
    383         FATAL("Unable to build the frame"); 
    384         return false; 
    385     } 
    386  
    387     //8. Compute the timestamp 
    388     _totalSentTime = (uint32_t) (_currentFrame.absoluteTime / 1000) - _totalSentTimeBase; 
    389  
    390     //9. Do the feedeng 
    391     if (!_pOutStreams->info->FeedData( 
    392             GETIBPOINTER(buffer), //pData 
    393             GETAVAILABLEBYTESCOUNT(buffer), //dataLength 
    394             0, //processedLength 
    395             GETAVAILABLEBYTESCOUNT(buffer), //totalLength 
    396             (uint32_t) _currentFrame.absoluteTime, //absoluteTimestamp 
    397             _currentFrame.type == MEDIAFRAME_TYPE_AUDIO //isAudio 
    398             )) { 
    399         FATAL("Unable to feed audio data"); 
    400         return false; 
    401     } 
    402  
    403     //10. Discard the data 
    404     buffer.IgnoreAll(); 
    405  
    406  
    407     //11. Increment the frame index 
    408     _currentFrameIndex++; 
    409  
    410     //12. Done 
    411     return true; 
     352        //1. Are we in paused state? 
     353        if (_paused) 
     354                return true; 
     355 
     356        //2. Determine if the client has enough data on the buffer and continue 
     357        //or stay put 
     358        uint32_t elapsedTime = (uint32_t) (time(NULL) - _startFeedingTime); 
     359        //    FINEST("tst: %d; et: %d; diff: %d", 
     360        //            _totalSentTime, elapsedTime, 
     361        //            (int32_t) _totalSentTime - (int32_t) elapsedTime); 
     362        if ((int32_t) _totalSentTime - (int32_t) elapsedTime >= _clientSideBufferLength) { 
     363                return true; 
     364        } 
     365 
     366        //3. Test to see if we have sent the last frame 
     367        if (_currentFrameIndex >= _totalFrames) { 
     368                FINEST("Done streaming file"); 
     369                _pOutStreams->info->SignalStreamCompleted(); 
     370                _paused = true; 
     371                return true; 
     372        } 
     373 
     374        //4. Read the current frame from the seeking file 
     375        if (!_pSeekFile->SeekTo(4 + _currentFrameIndex * sizeof (MediaFrame))) { 
     376                FATAL("Unablt to seek inside seek file"); 
     377                return false; 
     378        } 
     379        if (!_pSeekFile->ReadBuffer((uint8_t *) & _currentFrame, sizeof (_currentFrame))) { 
     380                FATAL("Unable to read frame from seeking file"); 
     381                return false; 
     382        } 
     383 
     384        //5. Skip on metadata 
     385        if (_currentFrame.type == MEDIAFRAME_TYPE_DATA) { 
     386                _currentFrameIndex++; 
     387                return Feed(); 
     388        } 
     389 
     390        //6. get our hands on the correct buffer, depending on the frame type: audio or video 
     391        IOBuffer &buffer = _currentFrame.type == MEDIAFRAME_TYPE_AUDIO ? _audioBuffer : _videoBuffer; 
     392 
     393        //7. Build the frame 
     394        if (!BuildFrame(_pFile, _currentFrame, buffer)) { 
     395                FATAL("Unable to build the frame"); 
     396                return false; 
     397        } 
     398 
     399        //8. Compute the timestamp 
     400        _totalSentTime = (uint32_t) (_currentFrame.absoluteTime / 1000) - _totalSentTimeBase; 
     401 
     402        //9. Do the feedeng 
     403        if (!_pOutStreams->info->FeedData( 
     404                        GETIBPOINTER(buffer), //pData 
     405                        GETAVAILABLEBYTESCOUNT(buffer), //dataLength 
     406                        0, //processedLength 
     407                        GETAVAILABLEBYTESCOUNT(buffer), //totalLength 
     408                        (uint32_t) _currentFrame.absoluteTime, //absoluteTimestamp 
     409                        _currentFrame.type == MEDIAFRAME_TYPE_AUDIO //isAudio 
     410                        )) { 
     411                FATAL("Unable to feed audio data"); 
     412                return false; 
     413        } 
     414 
     415        //10. Discard the data 
     416        buffer.IgnoreAll(); 
     417 
     418 
     419        //11. Increment the frame index 
     420        _currentFrameIndex++; 
     421 
     422        //12. Done 
     423        return true; 
    412424} 
    413425 
     
    415427 
    416428MmapFile* BaseInFileStream::GetFile(string filePath, uint32_t windowSize) { 
    417     if (windowSize == 0) 
    418         windowSize = 131072; 
    419     MmapFile *pResult = NULL; 
    420     pResult = new MmapFile(); 
    421     if (!pResult->Initialize(filePath, windowSize)) { 
    422         delete pResult; 
    423         return NULL; 
    424     } 
    425     return pResult; 
     429        if (windowSize == 0) 
     430                windowSize = 131072; 
     431        MmapFile *pResult = NULL; 
     432        pResult = new MmapFile(); 
     433        if (!pResult->Initialize(filePath, windowSize)) { 
     434                delete pResult; 
     435                return NULL; 
     436        } 
     437        return pResult; 
    426438} 
    427439 
    428440void BaseInFileStream::ReleaseFile(MmapFile *pFile) { 
    429     if (pFile == NULL) 
    430         return; 
    431     delete pFile; 
     441        if (pFile == NULL) 
     442                return; 
     443        delete pFile; 
    432444} 
    433445 
     
    435447 
    436448File* BaseInFileStream::GetFile(string filePath, uint32_t windowSize) { 
    437     File *pResult = NULL; 
    438     if (!MAP_HAS1(_fileCache, filePath)) { 
    439         pResult = new File(); 
    440         if (!pResult->Initialize(filePath)) { 
    441             delete pResult; 
    442             return NULL; 
    443         } 
    444         _fileCache[filePath] = pair<uint32_t, File *>(1, pResult); 
    445     } else { 
    446         pResult = _fileCache[filePath].second; 
    447         _fileCache[filePath].first++; 
    448         //FINEST("+Count: %d", _fileCache[filePath].first); 
    449     } 
    450     return pResult; 
     449        File *pResult = NULL; 
     450        if (!MAP_HAS1(_fileCache, filePath)) { 
     451                pResult = new File(); 
     452                if (!pResult->Initialize(filePath)) { 
     453                        delete pResult; 
     454                        return NULL; 
     455                } 
     456                _fileCache[filePath] = pair<uint32_t, File *>(1, pResult); 
     457        } else { 
     458                pResult = _fileCache[filePath].second; 
     459                _fileCache[filePath].first++; 
     460                //FINEST("+Count: %d", _fileCache[filePath].first); 
     461        } 
     462        return pResult; 
    451463} 
    452464 
    453465void BaseInFileStream::ReleaseFile(File *pFile) { 
    454     if (pFile == NULL) 
    455         return; 
    456     if (!MAP_HAS1(_fileCache, pFile->GetPath())) { 
    457         WARN("You tryed to release a non-cached file: %s", STR(pFile->GetPath())); 
    458         return; 
    459     } 
    460     _fileCache[pFile->GetPath()].first--; 
    461     if (_fileCache[pFile->GetPath()].first == 0) { 
    462         _fileCache.erase(pFile->GetPath()); 
    463         delete pFile; 
    464     } 
     466        if (pFile == NULL) 
     467                return; 
     468        if (!MAP_HAS1(_fileCache, pFile->GetPath())) { 
     469                WARN("You tryed to release a non-cached file: %s", STR(pFile->GetPath())); 
     470                return; 
     471        } 
     472        _fileCache[pFile->GetPath()].first--; 
     473        if (_fileCache[pFile->GetPath()].first == 0) { 
     474                _fileCache.erase(pFile->GetPath()); 
     475                delete pFile; 
     476        } 
    465477} 
    466478#endif /* HAS_MMAP */ 
  • trunk/sources/thelib/src/streaming/baseinnetstream.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2323 
    2424BaseInNetStream::BaseInNetStream(BaseProtocol *pProtocol, 
    25         StreamsManager *pStreamsManager, uint64_t type, string name) 
     25                StreamsManager *pStreamsManager, uint64_t type, string name) 
    2626: BaseInStream(pProtocol, pStreamsManager, type, name) { 
    27     if(!TAG_KIND_OF(type,ST_IN_NET)){ 
    28         ASSERT("Incorrect stream type. Wanted a stream type in class %s and got %s", 
    29                 STR(tagToString(ST_IN_NET)), STR(tagToString(type))); 
    30     } 
     27        if (!TAG_KIND_OF(type, ST_IN_NET)) { 
     28                ASSERT("Incorrect stream type. Wanted a stream type in class %s and got %s", 
     29                                STR(tagToString(ST_IN_NET)), STR(tagToString(type))); 
     30        } 
    3131} 
    3232 
  • trunk/sources/thelib/src/streaming/baseinstream.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
  • trunk/sources/thelib/src/streaming/baseoutfilestream.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2323 
    2424BaseOutFileStream::BaseOutFileStream(BaseProtocol *pProtocol, 
    25         StreamsManager *pStreamsManager, uint64_t type, string name) 
     25                StreamsManager *pStreamsManager, uint64_t type, string name) 
    2626: BaseOutStream(pProtocol, pStreamsManager, type, name) { 
    27     if(!TAG_KIND_OF(type,ST_OUT_FILE)){ 
    28         ASSERT("Incorrect stream type. Wanted a stream type in class %s and got %s", 
    29                 STR(tagToString(ST_OUT_FILE)), STR(tagToString(type))); 
    30     } 
     27        if (!TAG_KIND_OF(type, ST_OUT_FILE)) { 
     28                ASSERT("Incorrect stream type. Wanted a stream type in class %s and got %s", 
     29                                STR(tagToString(ST_OUT_FILE)), STR(tagToString(type))); 
     30        } 
    3131} 
    3232 
  • trunk/sources/thelib/src/streaming/baseoutnetstream.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2424 
    2525BaseOutNetStream::BaseOutNetStream(BaseProtocol *pProtocol, 
    26         StreamsManager *pStreamsManager, uint64_t type, string name) 
     26                StreamsManager *pStreamsManager, uint64_t type, string name) 
    2727: BaseOutStream(pProtocol, pStreamsManager, type, name) { 
    28     if(!TAG_KIND_OF(type,ST_OUT_NET)){ 
    29         ASSERT("Incorrect stream type. Wanted a stream type in class %s and got %s", 
    30                 STR(tagToString(ST_OUT_NET)), STR(tagToString(type))); 
    31     } 
     28        if (!TAG_KIND_OF(type, ST_OUT_NET)) { 
     29                ASSERT("Incorrect stream type. Wanted a stream type in class %s and got %s", 
     30                                STR(tagToString(ST_OUT_NET)), STR(tagToString(type))); 
     31        } 
    3232} 
    3333 
  • trunk/sources/thelib/src/streaming/baseoutstream.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2424 
    2525BaseOutStream::BaseOutStream(BaseProtocol *pProtocol, 
    26         StreamsManager *pStreamsManager, uint64_t type, string name) 
     26                StreamsManager *pStreamsManager, uint64_t type, string name) 
    2727: BaseStream(pProtocol, pStreamsManager, type, name) { 
    28     if (!TAG_KIND_OF(type, ST_OUT)) { 
    29         ASSERT("Incorrect stream type. Wanted a stream type in class %s and got %s", 
    30                 STR(tagToString(ST_OUT)), STR(tagToString(type))); 
    31     } 
    32     _canCallDetachedFromInStream = true; 
    33     _pInStream = NULL; 
     28        if (!TAG_KIND_OF(type, ST_OUT)) { 
     29                ASSERT("Incorrect stream type. Wanted a stream type in class %s and got %s", 
     30                                STR(tagToString(ST_OUT)), STR(tagToString(type))); 
     31        } 
     32        _canCallDetachedFromInStream = true; 
     33        _pInStream = NULL; 
    3434} 
    3535 
    3636BaseOutStream::~BaseOutStream() { 
    37     _canCallDetachedFromInStream = false; 
    38     UnLink(true); 
     37        _canCallDetachedFromInStream = false; 
     38        UnLink(true); 
    3939} 
    4040 
    4141StreamCapabilities * BaseOutStream::GetCapabilities() { 
    42     if (_pInStream != NULL) 
    43         return _pInStream->GetCapabilities(); 
    44     return NULL; 
     42        if (_pInStream != NULL) 
     43                return _pInStream->GetCapabilities(); 
     44        return NULL; 
    4545} 
    4646 
    4747void BaseOutStream::ReadyForSend() { 
    48     if (_pInStream != NULL) 
    49         _pInStream->ReadyForSend(); 
     48        if (_pInStream != NULL) 
     49                _pInStream->ReadyForSend(); 
    5050} 
    5151 
    5252bool BaseOutStream::Link(BaseInStream *pInStream, bool reverseLink) { 
    53     if ((!pInStream->IsCompatibleWithType(GetType())) 
    54             || (!IsCompatibleWithType(pInStream->GetType()))) { 
    55         FATAL("stream type %s not compatible with stream type %s", 
    56                 STR(tagToString(GetType())), 
    57                 STR(tagToString(pInStream->GetType()))); 
    58         return false; 
    59     } 
    60     //    FINEST("BaseOutStream::Link: this: %u; pInStream: %u; reverseLink: %d", 
    61     //            GetUniqueId(), pInStream->GetUniqueId(), reverseLink); 
    62     if (_pInStream != NULL) { 
    63         if (_pInStream->GetUniqueId() == pInStream->GetUniqueId()) { 
    64             WARN("BaseOutStream::Link: This stream is already linked"); 
    65             return true; 
    66         } 
    67         FATAL("BaseOutStream::Link: This stream is already linked to stream with unique id %u", 
    68                 _pInStream->GetUniqueId()); 
    69         return false; 
    70     } 
    71     //FINEST("BaseOutStream::Link: Linking..."); 
    72     _pInStream = pInStream; 
    73     if (reverseLink) { 
    74         //FINEST("BaseOutStream::Link: Reverse linking..."); 
    75         if (!_pInStream->Link(this, false)) { 
    76             FATAL("BaseOutStream::Link: Unable to reverse link"); 
    77             _pInStream = NULL; 
    78             return false; 
    79         } 
    80         //FINEST("BaseOutStream::Link: Done reverse link"); 
    81     } 
    82     //FINEST("BaseOutStream::Link: Signal AttachedToInStream"); 
    83     SignalAttachedToInStream(); 
    84     //FINEST("BaseOutStream::Link: Done"); 
    85     return true; 
     53        if ((!pInStream->IsCompatibleWithType(GetType())) 
     54                        || (!IsCompatibleWithType(pInStream->GetType()))) { 
     55                FATAL("stream type %s not compatible with stream type %s", 
     56                                STR(tagToString(GetType())), 
     57                                STR(tagToString(pInStream->GetType()))); 
     58                return false; 
     59        } 
     60        //    FINEST("BaseOutStream::Link: this: %u; pInStream: %u; reverseLink: %d", 
     61        //            GetUniqueId(), pInStream->GetUniqueId(), reverseLink); 
     62        if (_pInStream != NULL) { 
     63                if (_pInStream->GetUniqueId() == pInStream->GetUniqueId()) { 
     64                        WARN("BaseOutStream::Link: This stream is already linked"); 
     65                        return true; 
     66                } 
     67                FATAL("BaseOutStream::Link: This stream is already linked to stream with unique id %u", 
     68                                _pInStream->GetUniqueId()); 
     69                return false; 
     70        } 
     71        //FINEST("BaseOutStream::Link: Linking..."); 
     72        _pInStream = pInStream; 
     73        if (reverseLink) { 
     74                //FINEST("BaseOutStream::Link: Reverse linking..."); 
     75                if (!_pInStream->Link(this, false)) { 
     76                        FATAL("BaseOutStream::Link: Unable to reverse link"); 
     77                        _pInStream = NULL; 
     78                        return false; 
     79                } 
     80                //FINEST("BaseOutStream::Link: Done reverse link"); 
     81        } 
     82        //FINEST("BaseOutStream::Link: Signal AttachedToInStream"); 
     83        SignalAttachedToInStream(); 
     84        //FINEST("BaseOutStream::Link: Done"); 
     85        return true; 
    8686} 
    8787 
    8888bool BaseOutStream::UnLink(bool reverseUnLink) { 
    89     //    FINEST("BaseOutStream::UnLink: this: %u; _pInStream: %u; reverseUnLink: %d", 
    90     //            GetUniqueId(), _pInStream != NULL ? _pInStream->GetUniqueId() : 0, 
    91     //            reverseUnLink); 
    92     if (_pInStream == NULL) { 
    93         WARN("BaseOutStream::UnLink: This stream is not linked"); 
    94         return true; 
    95     } 
    96     if (reverseUnLink) { 
    97         //FINEST("BaseOutStream::UnLink: Reverse unLinking..."); 
    98         if (!_pInStream->UnLink(this, false)) { 
    99             FATAL("BaseOutStream::UnLink: Unable to reverse unLink"); 
    100             //TODO: what are we going to do here??? 
    101             NYIA; 
    102         } 
    103         //FINEST("BaseOutStream::UnLink: Done reverse unLink"); 
    104     } 
    105     //FINEST("BaseOutStream::UnLink: unLinking..."); 
    106     _pInStream = NULL; 
     89        //    FINEST("BaseOutStream::UnLink: this: %u; _pInStream: %u; reverseUnLink: %d", 
     90        //            GetUniqueId(), _pInStream != NULL ? _pInStream->GetUniqueId() : 0, 
     91        //            reverseUnLink); 
     92        if (_pInStream == NULL) { 
     93                WARN("BaseOutStream::UnLink: This stream is not linked"); 
     94                return true; 
     95        } 
     96        if (reverseUnLink) { 
     97                //FINEST("BaseOutStream::UnLink: Reverse unLinking..."); 
     98                if (!_pInStream->UnLink(this, false)) { 
     99                        FATAL("BaseOutStream::UnLink: Unable to reverse unLink"); 
     100                        //TODO: what are we going to do here??? 
     101                        NYIA; 
     102                } 
     103                //FINEST("BaseOutStream::UnLink: Done reverse unLink"); 
     104        } 
     105        //FINEST("BaseOutStream::UnLink: unLinking..."); 
     106        _pInStream = NULL; 
    107107 
    108     //    FINEST("BaseOutStream::UnLink: _canCallDetachedFromInStream: %d", 
    109     //            _canCallDetachedFromInStream); 
    110     if (_canCallDetachedFromInStream) { 
    111         //FINEST("BaseOutStream::UnLink: Signal DetachedFromInStream"); 
    112         SignalDetachedFromInStream(); 
    113     } 
    114     //FINEST("BaseOutStream::UnLink: Done"); 
    115     return true; 
     108        //    FINEST("BaseOutStream::UnLink: _canCallDetachedFromInStream: %d", 
     109        //            _canCallDetachedFromInStream); 
     110        if (_canCallDetachedFromInStream) { 
     111                //FINEST("BaseOutStream::UnLink: Signal DetachedFromInStream"); 
     112                SignalDetachedFromInStream(); 
     113        } 
     114        //FINEST("BaseOutStream::UnLink: Done"); 
     115        return true; 
    116116} 
    117117 
    118118bool BaseOutStream::IsLinked() { 
    119     return _pInStream != NULL; 
     119        return _pInStream != NULL; 
    120120} 
    121121 
    122122BaseInStream *BaseOutStream::GetInStream() { 
    123     return _pInStream; 
     123        return _pInStream; 
    124124} 
    125125 
    126126bool BaseOutStream::Play(double absoluteTimestamp, double length) { 
    127     if (_pInStream != NULL) { 
    128         if (!_pInStream->SignalPlay(absoluteTimestamp, length)) { 
    129             FATAL("Unable to signal play"); 
    130             return false; 
    131         } 
    132     } 
    133     return SignalPlay(absoluteTimestamp, length); 
     127        if (_pInStream != NULL) { 
     128                if (!_pInStream->SignalPlay(absoluteTimestamp, length)) { 
     129                        FATAL("Unable to signal play"); 
     130                        return false; 
     131                } 
     132        } 
     133        return SignalPlay(absoluteTimestamp, length); 
    134134} 
    135135 
    136136bool BaseOutStream::Pause() { 
    137     if (_pInStream != NULL) { 
    138         if (!_pInStream->SignalPause()) { 
    139             FATAL("Unable to signal pause"); 
    140             return false; 
    141         } 
    142     } 
    143     return SignalPause(); 
     137        if (_pInStream != NULL) { 
     138                if (!_pInStream->SignalPause()) { 
     139                        FATAL("Unable to signal pause"); 
     140                        return false; 
     141                } 
     142        } 
     143        return SignalPause(); 
    144144} 
    145145 
    146146bool BaseOutStream::Resume() { 
    147     if (_pInStream != NULL) { 
    148         if (!_pInStream->SignalResume()) { 
    149             FATAL("Unable to signal resume"); 
    150             return false; 
    151         } 
    152     } 
    153     return SignalResume(); 
     147        if (_pInStream != NULL) { 
     148                if (!_pInStream->SignalResume()) { 
     149                        FATAL("Unable to signal resume"); 
     150                        return false; 
     151                } 
     152        } 
     153        return SignalResume(); 
    154154} 
    155155 
    156156bool BaseOutStream::Seek(double absoluteTimestamp) { 
    157     if (!SignalSeek(absoluteTimestamp)) { 
    158         FATAL("Unable to signal seek"); 
    159         return false; 
    160     } 
     157        if (!SignalSeek(absoluteTimestamp)) { 
     158                FATAL("Unable to signal seek"); 
     159                return false; 
     160        } 
    161161 
    162     if (_pInStream != NULL) { 
    163         if (!_pInStream->SignalSeek(absoluteTimestamp)) { 
    164             FATAL("Unable to signal seek"); 
    165             return false; 
    166         } 
    167     } 
     162        if (_pInStream != NULL) { 
     163                if (!_pInStream->SignalSeek(absoluteTimestamp)) { 
     164                        FATAL("Unable to signal seek"); 
     165                        return false; 
     166                } 
     167        } 
    168168 
    169     return true; 
     169        return true; 
    170170} 
    171171 
    172172bool BaseOutStream::Stop() { 
    173     if (_pInStream != NULL) { 
    174         if (!_pInStream->SignalStop()) { 
    175             FATAL("Unable to signal stop"); 
    176             return false; 
    177         } 
    178     } 
    179     return SignalStop(); 
     173        if (_pInStream != NULL) { 
     174                if (!_pInStream->SignalStop()) { 
     175                        FATAL("Unable to signal stop"); 
     176                        return false; 
     177                } 
     178        } 
     179        return SignalStop(); 
    180180} 
    181181 
  • trunk/sources/thelib/src/streaming/basestream.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2424 
    2525BaseStream::BaseStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, 
    26         uint64_t type, string name) { 
    27     _pStreamsManager = pStreamsManager; 
    28     _type = type; 
    29     _uniqueId = _pStreamsManager->GenerateUniqueId(); 
    30     _pProtocol = pProtocol; 
    31     _name = name; 
    32     _pStreamsManager->RegisterStream(this); 
    33     //FINEST("Stream %u created: %s", _uniqueId, STR(tagToString(_type))); 
     26                uint64_t type, string name) { 
     27        _pStreamsManager = pStreamsManager; 
     28        _type = type; 
     29        _uniqueId = _pStreamsManager->GenerateUniqueId(); 
     30        _pProtocol = pProtocol; 
     31        _name = name; 
     32        _pStreamsManager->RegisterStream(this); 
     33        //FINEST("Stream %u created: %s", _uniqueId, STR(tagToString(_type))); 
    3434} 
    3535 
    3636BaseStream::~BaseStream() { 
    37     _pStreamsManager->UnRegisterStream(this); 
    38     //FINEST("Stream %u deleted: %s", _uniqueId, STR(tagToString(_type))); 
     37        _pStreamsManager->UnRegisterStream(this); 
     38        //FINEST("Stream %u deleted: %s", _uniqueId, STR(tagToString(_type))); 
    3939} 
    4040 
    4141StreamsManager *BaseStream::GetStreamsManager() { 
    42     return _pStreamsManager; 
     42        return _pStreamsManager; 
    4343} 
    4444 
    4545uint64_t BaseStream::GetType() { 
    46     return _type; 
     46        return _type; 
    4747} 
    4848 
    4949uint32_t BaseStream::GetUniqueId() { 
    50     return _uniqueId; 
     50        return _uniqueId; 
    5151} 
    5252 
    5353string BaseStream::GetName() { 
    54     return _name; 
     54        return _name; 
    5555} 
    5656 
    5757void BaseStream::SetName(string name) { 
    58     if (_name != "") { 
    59         ASSERT("name already set"); 
    60     } 
    61     _name = name; 
     58        if (_name != "") { 
     59                ASSERT("name already set"); 
     60        } 
     61        _name = name; 
    6262} 
    6363 
    6464BaseProtocol * BaseStream::GetProtocol() { 
    65     return _pProtocol; 
     65        return _pProtocol; 
    6666} 
    6767 
    6868bool BaseStream::IsEnqueueForDelete() { 
    69     if (_pProtocol != NULL) 
    70         return _pProtocol->IsEnqueueForDelete(); 
    71     return false; 
     69        if (_pProtocol != NULL) 
     70                return _pProtocol->IsEnqueueForDelete(); 
     71        return false; 
    7272} 
    7373 
    7474void BaseStream::EnqueueForDelete() { 
    75     if (_pProtocol != NULL) { 
    76         _pProtocol->EnqueueForDelete(); 
    77     } else { 
    78         delete this; 
    79     } 
     75        if (_pProtocol != NULL) { 
     76                _pProtocol->EnqueueForDelete(); 
     77        } else { 
     78                delete this; 
     79        } 
    8080} 
    8181 
  • trunk/sources/thelib/src/streaming/nalutypes.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2323 
    2424string NALUToString(uint8_t naluType) { 
    25     switch (NALU_TYPE(naluType)) { 
    26         case NALU_TYPE_SLICE: return "SLICE"; 
    27         case NALU_TYPE_DPA: return "DPA"; 
    28         case NALU_TYPE_DPB: return "DPB"; 
    29         case NALU_TYPE_DPC: return "DPC"; 
    30         case NALU_TYPE_IDR: return "IDR"; 
    31         case NALU_TYPE_SEI: return "SEI"; 
    32         case NALU_TYPE_SPS: return "SPS"; 
    33         case NALU_TYPE_PPS: return "PPS"; 
    34         case NALU_TYPE_PD: return "PD"; 
    35         case NALU_TYPE_EOSEQ: return "EOSEQ"; 
    36         case NALU_TYPE_EOSTREAM: return "EOSTREAM"; 
    37         case NALU_TYPE_FILL: return "FILL"; 
    38         case NALU_TYPE_RESERVED13: return "RESERVED13"; 
    39         case NALU_TYPE_RESERVED14: return "RESERVED14"; 
    40         case NALU_TYPE_RESERVED15: return "RESERVED15"; 
    41         case NALU_TYPE_RESERVED16: return "RESERVED16"; 
    42         case NALU_TYPE_RESERVED17: return "RESERVED17"; 
    43         case NALU_TYPE_RESERVED18: return "RESERVED18"; 
    44         case NALU_TYPE_RESERVED19: return "RESERVED19"; 
    45         case NALU_TYPE_RESERVED20: return "RESERVED20"; 
    46         case NALU_TYPE_RESERVED21: return "RESERVED21"; 
    47         case NALU_TYPE_RESERVED22: return "RESERVED22"; 
    48         case NALU_TYPE_RESERVED23: return "RESERVED23"; 
    49         case NALU_TYPE_STAPA: return "STAPA"; 
    50         case NALU_TYPE_STAPB: return "STAPB"; 
    51         case NALU_TYPE_MTAP16: return "MTAP16"; 
    52         case NALU_TYPE_MTAP24: return "MTAP24"; 
    53         case NALU_TYPE_FUA: return "FUA"; 
    54         case NALU_TYPE_FUB: return "FUB"; 
    55         case NALU_TYPE_RESERVED30: return "RESERVED30"; 
    56         case NALU_TYPE_RESERVED31: return "RESERVED31"; 
    57         case NALU_TYPE_UNDEFINED: 
    58         default: 
    59             return "UNDEFINED"; 
    60     } 
     25        switch (NALU_TYPE(naluType)) { 
     26                case NALU_TYPE_SLICE: return "SLICE"; 
     27                case NALU_TYPE_DPA: return "DPA"; 
     28                case NALU_TYPE_DPB: return "DPB"; 
     29                case NALU_TYPE_DPC: return "DPC"; 
     30                case NALU_TYPE_IDR: return "IDR"; 
     31                case NALU_TYPE_SEI: return "SEI"; 
     32                case NALU_TYPE_SPS: return "SPS"; 
     33                case NALU_TYPE_PPS: return "PPS"; 
     34                case NALU_TYPE_PD: return "PD"; 
     35                case NALU_TYPE_EOSEQ: return "EOSEQ"; 
     36                case NALU_TYPE_EOSTREAM: return "EOSTREAM"; 
     37                case NALU_TYPE_FILL: return "FILL"; 
     38                case NALU_TYPE_RESERVED13: return "RESERVED13"; 
     39                case NALU_TYPE_RESERVED14: return "RESERVED14"; 
     40                case NALU_TYPE_RESERVED15: return "RESERVED15"; 
     41                case NALU_TYPE_RESERVED16: return "RESERVED16"; 
     42                case NALU_TYPE_RESERVED17: return "RESERVED17"; 
     43                case NALU_TYPE_RESERVED18: return "RESERVED18"; 
     44                case NALU_TYPE_RESERVED19: return "RESERVED19"; 
     45                case NALU_TYPE_RESERVED20: return "RESERVED20"; 
     46                case NALU_TYPE_RESERVED21: return "RESERVED21"; 
     47                case NALU_TYPE_RESERVED22: return "RESERVED22"; 
     48                case NALU_TYPE_RESERVED23: return "RESERVED23"; 
     49                case NALU_TYPE_STAPA: return "STAPA"; 
     50                case NALU_TYPE_STAPB: return "STAPB"; 
     51                case NALU_TYPE_MTAP16: return "MTAP16"; 
     52                case NALU_TYPE_MTAP24: return "MTAP24"; 
     53                case NALU_TYPE_FUA: return "FUA"; 
     54                case NALU_TYPE_FUB: return "FUB"; 
     55                case NALU_TYPE_RESERVED30: return "RESERVED30"; 
     56                case NALU_TYPE_RESERVED31: return "RESERVED31"; 
     57                case NALU_TYPE_UNDEFINED: 
     58                default: 
     59                        return "UNDEFINED"; 
     60        } 
    6161} 
    6262 
  • trunk/sources/thelib/src/streaming/streamsmanager.cpp

    r2 r10  
    11/*  
    2 *  Copyright (c) 2010, 
    3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  
    5 *  This file is part of crtmpserver. 
    6 *  crtmpserver is free software: you can redistribute it and/or modify 
    7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
    15  
    16 *  You should have received a copy of the GNU General Public License 
    17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
    18 */ 
     2 *  Copyright (c) 2010, 
     3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     4 * 
     5 *  This file is part of crtmpserver. 
     6 *  crtmpserver is free software: you can redistribute it and/or modify 
     7 *  it under the terms of the GNU 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 *  crtmpserver 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 General Public License for more details. 
     15 * 
     16 *  You should have received a copy of the GNU General Public License 
     17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     18 */ 
    1919 
    2020 
     
    2525 
    2626StreamsManager::StreamsManager(BaseClientApplication *pApplication) { 
    27     _uniqueIdGenerator = 1; 
    28     _pApplication = pApplication; 
     27        _uniqueIdGenerator = 1; 
     28        _pApplication = pApplication; 
    2929} 
    3030 
     
    3333 
    3434uint32_t StreamsManager::GenerateUniqueId() { 
    35     return _uniqueIdGenerator++; 
     35        return _uniqueIdGenerator++; 
    3636} 
    3737 
    3838bool StreamsManager::RegisterStream(BaseStream *pStream) { 
    39     //1. Test to see if we had registered this stream before 
    40     if (MAP_HAS1(_streamsByUniqueId, pStream->GetUniqueId())) { 
    41         FATAL("Stream with unique ID %lu already registered", pStream->GetUniqueId()); 
    42         return false; 
    43     } 
    44  
    45     //2. Register the stream 
    46     _streamsByUniqueId[pStream->GetUniqueId()] = pStream; 
    47     if (pStream->GetProtocol() != NULL) 
    48         _streamsByProtocolId[pStream->GetProtocol()->GetId()][pStream->GetUniqueId()] = pStream; 
    49     _streamsByType[pStream->GetType()][pStream->GetUniqueId()] = pStream; 
    50     _streamsByName[pStream->GetName()][pStream->GetUniqueId()] = pStream; 
    51  
    52     _pApplication->SignalStreamRegistered(pStream); 
    53  
    54     //3. Done 
    55     return true; 
     39        //1. Test to see if we had registered this stream before 
     40        if (MAP_HAS1(_streamsByUniqueId, pStream->GetUniqueId())) { 
     41                FATAL("Stream with unique ID %lu already registered", pStream->GetUniqueId()); 
     42                return false; 
     43        } 
     44 
     45        //2. Register the stream 
     46        _streamsByUniqueId[pStream->GetUniqueId()] = pStream; 
     47        if (pStream->GetProtocol() != NULL) 
     48                _streamsByProtocolId[pStream->GetProtocol()->GetId()][pStream->GetUniqueId()] = pStream; 
     49        _streamsByType[pStream->GetType()][pStream->GetUniqueId()] = pStream; 
     50        _streamsByName[pStream->GetName()][pStream->GetUniqueId()] = pStream; 
     51 
     52        _pApplication->SignalStreamRegistered(pStream); 
     53 
     54        //3. Done 
     55        return true; 
    5656} 
    5757 
    5858void StreamsManager::UnRegisterStream(BaseStream *pStream) { 
    59     MAP_ERASE1(_streamsByUniqueId, pStream->GetUniqueId()); 
    60     if (pStream->GetProtocol() != NULL) 
    61         MAP_ERASE2(_streamsByProtocolId, pStream->GetProtocol()->GetId(), pStream->GetUniqueId()); 
    62     MAP_ERASE2(_streamsByType, pStream->GetType(), pStream->GetUniqueId()); 
    63     MAP_ERASE2(_streamsByName, pStream->GetName(), pStream->GetUniqueId()); 
    64     _pApplication->SignalStreamUnRegistered(pStream); 
     59        MAP_ERASE1(_streamsByUniqueId, pStream->GetUniqueId()); 
     60        if (pStream->GetProtocol() != NULL) 
     61                MAP_ERASE2(_streamsByProtocolId, pStream->GetProtocol()->GetId(), pStream->GetUniqueId()); 
     62        MAP_ERASE2(_streamsByType, pStream->GetType(), pStream->GetUniqueId()); 
     63        MAP_ERASE2(_streamsByName, pStream->GetName(), pStream->GetUniqueId()); 
     64        _pApplication->SignalStreamUnRegistered(pStream); 
    6565} 
    6666 
    6767void StreamsManager::UnRegisterStreams(uint32_t protocolId) { 
    68     map<uint32_t, BaseStream *> streams = FindByProtocolId(protocolId); 
    69  
    70     FOR_MAP(streams, uint32_t, BaseStream *, i) { 
    71         UnRegisterStream(MAP_VAL(i)); 
    72     } 
     68        map<uint32_t, BaseStream *> streams = FindByProtocolId(protocolId); 
     69 
     70        FOR_MAP(streams, uint32_t, BaseStream *, i) { 
     71                UnRegisterStream(MAP_VAL(i)); 
     72        } 
    7373} 
    7474 
    7575map<uint32_t, BaseStream *> StreamsManager::FindByName(string name, bool partial) { 
    76     map<uint32_t, BaseStream * > result; 
    77  
    78     if (!partial) { 
    79         if (MAP_HAS1(_streamsByName, name)) 
    80             return _streamsByName[name]; 
    81         return result; 
    82     } 
    83  
    84  
    85     for (map<string, map<uint32_t, BaseStream * > >::iterator i = _streamsByName.begin(); 
    86             i != _streamsByName.end(); i++) { 
    87         if (MAP_KEY(i).find(name) == 0) { 
    88  
    89             FOR_MAP(MAP_VAL(i), uint32_t, BaseStream *, j) { 
    90                 result[MAP_KEY(j)] = MAP_VAL(j); 
    91             } 
    92         } 
    93     } 
    94     return result; 
     76        map<uint32_t, BaseStream * > result; 
     77 
     78        if (!partial) { 
     79                if (MAP_HAS1(_streamsByName, name)) 
     80                        return _streamsByName[name]; 
     81                return result; 
     82        } 
     83 
     84 
     85        for (map<string, map<uint32_t, BaseStream * > >::iterator i = _streamsByName.begin(); 
     86                        i != _streamsByName.end(); i++) { 
     87                if (MAP_KEY(i).find(name) == 0) { 
     88 
     89                        FOR_MAP(MAP_VAL(i), uint32_t, BaseStream *, j) { 
     90                                result[MAP_KEY(j)] = MAP_VAL(j); 
     91                        } 
     92                } 
     93        } 
     94        return result; 
    9595} 
    9696 
    9797map<uint32_t, BaseStream *> StreamsManager::FindByType(uint64_t type, bool partial) { 
    98     //    FINEST("FindByType: type: %s; partial: %d", 
    99     //            STR(tagToString(type)), partial); 
    100     map<uint32_t, BaseStream * > result; 
    101  
    102     if (!partial) { 
    103         if (MAP_HAS1(_streamsByType, type)) 
    104             return _streamsByType[type]; 
    105         return result; 
    106     } 
    107  
    108     uint64_t mask = getTagMask(type); 
    109  
    110     for (map<uint64_t, map<uint32_t, BaseStream * > >::iterator i = _streamsByType.begin(); 
    111             i != _streamsByType.end(); i++) { 
    112         //        FINEST("FindByType: MAP_KEY(i): %016llx; mask: %016llx; type: %016llx; (MAP_KEY(i) & mask): %016llx", 
    113         //                MAP_KEY(i), mask, type, (MAP_KEY(i) & mask)); 
    114         if ((MAP_KEY(i) & mask) == type) { 
    115             //FINEST("FindByType: matched"); 
    116  
    117             FOR_MAP(MAP_VAL(i), uint32_t, BaseStream *, j) { 
    118                 result[MAP_KEY(j)] = MAP_VAL(j); 
    119             } 
    120         } 
    121     } 
    122  
    123     return result; 
     98        //    FINEST("FindByType: type: %s; partial: %d", 
     99        //            STR(tagToString(type)), partial); 
     100        map<uint32_t, BaseStream * > result; 
     101 
     102        if (!partial) { 
     103                if (MAP_HAS1(_streamsByType, type)) 
     104                        return _streamsByType[type]; 
     105                return result; 
     106        } 
     107 
     108        uint64_t mask = getTagMask(type); 
     109 
     110        for (map<uint64_t, map<uint32_t, BaseStream * > >::iterator i = _streamsByType.begin(); 
     111                        i != _streamsByType.end(); i++) { 
     112                //        FINEST("FindByType: MAP_KEY(i): %016llx; mask: %016llx; type: %016llx; (MAP_KEY(i) & mask): %016llx", 
     113                //                MAP_KEY(i), mask, type, (MAP_KEY(i) & mask)); 
     114                if ((MAP_KEY(i) & mask) == type) { 
     115                        //FINEST("FindByType: matched"); 
     116 
     117                        FOR_MAP(MAP_VAL(i), uint32_t, BaseStream *, j) { 
     118                                result[MAP_KEY(j)] = MAP_VAL(j); 
     119                        } 
     120                } 
     121        } 
     122 
     123        return result; 
    124124} 
    125125 
    126126map<uint32_t, BaseStream *> StreamsManager::FindByTypeByName(uint64_t type, 
    127         string name, bool partialType, bool partialName) { 
    128     //    FINEST("FindByTypeByName: type: %s; name: %s; partialType: %d; partialName: %d", 
    129     //            STR(tagToString(type)), STR(name), partialType, partialName); 
    130     //1. Filter on type 
    131     map<uint32_t, BaseStream * > possibleResults = FindByType(type, partialType); 
    132  
    133     //    FOR_MAP(possibleResults, uint32_t, BaseStream *, i) { 
    134     //        FINEST("FindByTypeByName: filer on type: UID: %u; type: %s", 
    135     //                MAP_VAL(i)->GetUniqueId(), 
    136     //                STR(tagToString(MAP_VAL(i)->GetType()))); 
    137     //    } 
    138  
    139     //2. Filter on name 
    140     map<uint32_t, BaseStream * > result; 
    141  
    142     FOR_MAP(possibleResults, uint32_t, BaseStream *, i) { 
    143         if (partialName) { 
    144             if (MAP_VAL(i)->GetName().find(name) == 0) 
    145                 result[MAP_KEY(i)] = MAP_VAL(i); 
    146         } else { 
    147             if (MAP_VAL(i)->GetName() == name) 
    148                 result[MAP_KEY(i)] = MAP_VAL(i); 
    149         } 
    150     } 
    151  
    152     //3. Done 
    153     return result; 
     127                string name, bool partialType, bool partialName) { 
     128        //    FINEST("FindByTypeByName: type: %s; name: %s; partialType: %d; partialName: %d", 
     129        //            STR(tagToString(type)), STR(name), partialType, partialName); 
     130        //1. Filter on type 
     131        map<uint32_t, BaseStream * > possibleResults = FindByType(type, partialType); 
     132 
     133        //    FOR_MAP(possibleResults, uint32_t, BaseStream *, i) { 
     134        //        FINEST("FindByTypeByName: filer on type: UID: %u; type: %s", 
     135        //                MAP_VAL(i)->GetUniqueId(), 
     136        //                STR(tagToString(MAP_VAL(i)->GetType()))); 
     137        //    } 
     138 
     139        //2. Filter on name 
     140        map<uint32_t, BaseStream * > result; 
     141 
     142        FOR_MAP(possibleResults, uint32_t, BaseStream *, i) { 
     143                if (partialName) { 
     144                        if (MAP_VAL(i)->GetName().find(name) == 0) 
     145                                result[MAP_KEY(i)] = MAP_VAL(i); 
     146                } else { 
     147                        if (MAP_VAL(i)->GetName() == name) 
     148                                result[MAP_KEY(i)] = MAP_VAL(i); 
     149                } 
     150        } 
     151 
     152        //3. Done 
     153        return result; 
    154154} 
    155155 
    156156map<uint32_t, BaseStream *> StreamsManager::FindByProtocolId(uint32_t protocolId) { 
    157     map<uint32_t, BaseStream * > result; 
    158     if (MAP_HAS1(_streamsByProtocolId, protocolId)) 
    159         return _streamsByProtocolId[protocolId]; 
    160     return result; 
     157        map<uint32_t, BaseStream * > result; 
     158        if (MAP_HAS1(_streamsByProtocolId, protocolId)) 
     159                return _streamsByProtocolId[protocolId]; 
     160        return result; 
    161161} 
    162162 
    163163map<uint32_t, BaseStream *> StreamsManager::FindByProtocolIdByType( 
    164         uint32_t protocolId, uint64_t type, bool partial) { 
    165     //1. Filter on protocol id 
    166     map<uint32_t, BaseStream * > possibleResults = FindByProtocolId(protocolId); 
    167  
    168     //2. Filter on type 
    169     map<uint32_t, BaseStream * > result; 
    170     uint64_t mask = partial ? getTagMask(type) : 0xffffffffffffffffLL; 
    171  
    172     FOR_MAP(possibleResults, uint32_t, BaseStream *, i) { 
    173         if ((MAP_VAL(i)->GetType() & mask) == type) 
    174             result[MAP_KEY(i)] = MAP_VAL(i); 
    175     } 
    176  
    177     //3. Done 
    178     return result; 
     164                uint32_t protocolId, uint64_t type, bool partial) { 
     165        //1. Filter on protocol id 
     166        map<uint32_t, BaseStream * > possibleResults = FindByProtocolId(protocolId); 
     167 
     168        //2. Filter on type 
     169        map<uint32_t, BaseStream * > result; 
     170        uint64_t mask = partial ? getTagMask(type) : 0xffffffffffffffffLL; 
     171 
     172        FOR_MAP(possibleResults, uint32_t, BaseStream *, i) { 
     173                if ((MAP_VAL(i)->GetType() & mask) == type) 
     174                        result[MAP_KEY(i)] = MAP_VAL(i); 
     175        } 
     176 
     177        //3. Done 
     178        return result; 
    179179} 
    180180 
    181181map<uint32_t, BaseStream *> StreamsManager::FindByProtocolIdByName(uint32_t protocolId, 
    182         string name, bool partial) { 
    183     //1. Filter on protocol id 
    184     map<uint32_t, BaseStream * > possibleResults = FindByProtocolId(protocolId); 
    185  
    186     //2. Filter on name 
    187     map<uint32_t, BaseStream * > result; 
    188  
    189     FOR_MAP(possibleResults, uint32_t, BaseStream *, i) { 
    190         if (partial) { 
    191             if (MAP_VAL(i)->GetName().find(name) == 0) 
    192                 result[MAP_KEY(i)] = MAP_VAL(i); 
    193         } else { 
    194             if (MAP_VAL(i)->GetName() == name) 
    195                 result[MAP_KEY(i)] = MAP_VAL(i); 
    196         } 
    197     } 
    198  
    199     //3. Done 
    200     return result; 
     182                string name, bool partial) { 
     183        //1. Filter on protocol id 
     184        map<uint32_t, BaseStream * > possibleResults = FindByProtocolId(protocolId); 
     185 
     186        //2. Filter on name 
     187        map<uint32_t, BaseStream * > result; 
     188 
     189        FOR_MAP(possibleResults, uint32_t, BaseStream *, i) { 
     190                if (partial) { 
     191                        if (MAP_VAL(i)->GetName().find(name) == 0) 
     192                                result[MAP_KEY(i)] = MAP_VAL(i); 
     193                } else { 
     194                        if (MAP_VAL(i)->GetName() == name) 
     195                                result[MAP_KEY(i)] = MAP_VAL(i); 
     196                } 
     197        } 
     198 
     199        //3. Done 
     200        return result; 
    201201} 
    202202 
    203203map<uint32_t, BaseStream *> StreamsManager::FindByProtocolIdByTypeByName( 
    204         uint32_t protocolId, uint64_t type, string name, bool partialType, 
    205         bool partialName) { 
    206     //1. Filter on protocol id 
    207     map<uint32_t, BaseStream * > possibleResults1 = FindByProtocolId(protocolId); 
    208  
    209     //2. Filter on type 
    210     map<uint32_t, BaseStream * > possibleResults2; 
    211     uint64_t mask = partialType ? getTagMask(type) : 0xffffffffffffffffLL; 
    212  
    213     FOR_MAP(possibleResults1, uint32_t, BaseStream *, i) { 
    214         if ((MAP_VAL(i)->GetType() & mask) == type) 
    215             possibleResults2[MAP_KEY(i)] = MAP_VAL(i); 
    216     } 
    217  
    218     //3. Filter on name 
    219     map<uint32_t, BaseStream * > result; 
    220  
    221     FOR_MAP(possibleResults2, uint32_t, BaseStream *, i) { 
    222         if (partialName) { 
    223             if (MAP_VAL(i)->GetName().find(name) == 0) 
    224                 result[MAP_KEY(i)] = MAP_VAL(i); 
    225         } else { 
    226             if (MAP_VAL(i)->GetName() == name) 
    227                 result[MAP_KEY(i)] = MAP_VAL(i); 
    228         } 
    229     } 
    230  
    231     //4. Done 
    232     return result; 
     204                uint32_t protocolId, uint64_t type, string name, bool partialType, 
     205                bool partialName) { 
     206        //1. Filter on protocol id 
     207        map<uint32_t, BaseStream * > possibleResults1 = FindByProtocolId(protocolId); 
     208 
     209        //2. Filter on type 
     210        map<uint32_t, BaseStream * > possibleResults2; 
     211        uint64_t mask = partialType ? getTagMask(type) : 0xffffffffffffffffLL; 
     212 
     213        FOR_MAP(possibleResults1, uint32_t, BaseStream *, i) { 
     214                if ((MAP_VAL(i)->GetType() & mask) == type) 
     215                        possibleResults2[MAP_KEY(i)] = MAP_VAL(i); 
     216        } 
     217 
     218        //3. Filter on name 
     219        map<uint32_t, BaseStream * > result; 
     220 
     221        FOR_MAP(possibleResults2, uint32_t, BaseStream *, i) { 
     222                if (partialName) { 
     223                        if (MAP_VAL(i)->GetName().find(name) == 0) 
     224                                result[MAP_KEY(i)] = MAP_VAL(i); 
     225                } else { 
     226                        if (MAP_VAL(i)->GetName() == name) 
     227                                result[MAP_KEY(i)] = MAP_VAL(i); 
     228                } 
     229        } 
     230 
     231        //4. Done 
     232        return result; 
    233233} 
    234234 
    235235BaseStream * StreamsManager::FindByUniqueId(uint32_t uniqueId) { 
    236     if (MAP_HAS1(_streamsByUniqueId, uniqueId)) 
    237         return _streamsByUniqueId[uniqueId]; 
    238     return NULL; 
    239 } 
    240  
     236        if (MAP_HAS1(_streamsByUniqueId, uniqueId)) 
     237                return _streamsByUniqueId[uniqueId]; 
     238        return NULL; 
     239} 
     240 
Note: See TracChangeset for help on using the changeset viewer.