winlin

add amf0 decode framework.

@@ -85,7 +85,8 @@ ModuleLibIncs=(${LibSTRoot}) @@ -85,7 +85,8 @@ ModuleLibIncs=(${LibSTRoot})
85 MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server" 85 MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server"
86 "srs_core_error" "srs_core_conn" "srs_core_client" 86 "srs_core_error" "srs_core_conn" "srs_core_client"
87 "srs_core_rtmp" "srs_core_socket" "srs_core_buffer" 87 "srs_core_rtmp" "srs_core_socket" "srs_core_buffer"
88 - "srs_core_auto_free" "srs_core_protocol") 88 + "srs_core_auto_free" "srs_core_protocol" "srs_core_amf0"
  89 + "srs_core_stream")
89 MODULE_DIR="src/core" . auto/modules.sh 90 MODULE_DIR="src/core" . auto/modules.sh
90 CORE_OBJS="${MODULE_OBJS[@]}" 91 CORE_OBJS="${MODULE_OBJS[@]}"
91 92
@@ -42,4 +42,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -42,4 +42,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 #include <assert.h> 42 #include <assert.h>
43 #define srs_assert(expression) assert(expression) 43 #define srs_assert(expression) assert(expression)
44 44
  45 +#include <stddef.h>
  46 +
45 #endif 47 #endif
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
  24 +#include <srs_core_amf0.hpp>
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
  24 +#ifndef SRS_CORE_AMF0_HPP
  25 +#define SRS_CORE_AMF0_HPP
  26 +
  27 +/*
  28 +#include <srs_core_amf0.hpp>
  29 +*/
  30 +
  31 +#include <srs_core.hpp>
  32 +
  33 +#endif
@@ -30,8 +30,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -30,8 +30,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 30
31 #include <srs_core.hpp> 31 #include <srs_core.hpp>
32 32
33 -#include <stddef.h>  
34 -  
35 /** 33 /**
36 * auto free the instance in the current scope. 34 * auto free the instance in the current scope.
37 */ 35 */
@@ -53,4 +53,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -53,4 +53,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53 #define ERROR_RTMP_CHUNK_START 301 53 #define ERROR_RTMP_CHUNK_START 301
54 #define ERROR_RTMP_MSG_INVLIAD_SIZE 302 54 #define ERROR_RTMP_MSG_INVLIAD_SIZE 302
55 55
  56 +#define ERROR_SYSTEM_STREAM_INIT 400
  57 +
56 #endif 58 #endif
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
  24 +#include <srs_core_stream.hpp>
  25 +
  26 +#include <srs_core_log.hpp>
  27 +#include <srs_core_error.hpp>
  28 +
  29 +SrsStream::SrsStream()
  30 +{
  31 + bytes = NULL;
  32 + size = 0;
  33 +}
  34 +
  35 +SrsStream::~SrsStream()
  36 +{
  37 +}
  38 +
  39 +int SrsStream::initialize(char* _bytes, int _size)
  40 +{
  41 + int ret = ERROR_SUCCESS;
  42 +
  43 + if (!_bytes) {
  44 + ret = ERROR_SYSTEM_STREAM_INIT;
  45 + srs_error("stream param bytes must not be NULL. ret=%d", ret);
  46 + return ret;
  47 + }
  48 +
  49 + if (_size <= 0) {
  50 + ret = ERROR_SYSTEM_STREAM_INIT;
  51 + srs_error("stream param size must be positive. ret=%d", ret);
  52 + return ret;
  53 + }
  54 +
  55 + size = _size;
  56 + bytes = _bytes;
  57 +
  58 + return ret;
  59 +}
  60 +
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
  24 +#ifndef SRS_CORE_STREAM_HPP
  25 +#define SRS_CORE_STREAM_HPP
  26 +
  27 +/*
  28 +#include <srs_core_stream.hpp>
  29 +*/
  30 +
  31 +#include <srs_core.hpp>
  32 +
  33 +class SrsStream
  34 +{
  35 +protected:
  36 + char* bytes;
  37 + int size;
  38 +public:
  39 + SrsStream();
  40 + virtual ~SrsStream();
  41 +public:
  42 + /**
  43 + * initialize the stream from bytes.
  44 + * @_bytes, must not be NULL, or return error.
  45 + * @_size, must be positive, or return error.
  46 + * @remark, stream never free the _bytes, user must free it.
  47 + */
  48 + virtual int initialize(char* _bytes, int _size);
  49 +};
  50 +
  51 +#endif
@@ -18,6 +18,10 @@ file @@ -18,6 +18,10 @@ file
18 ..\core\srs_core_rtmp.cpp, 18 ..\core\srs_core_rtmp.cpp,
19 ..\core\srs_core_protocol.hpp, 19 ..\core\srs_core_protocol.hpp,
20 ..\core\srs_core_protocol.cpp, 20 ..\core\srs_core_protocol.cpp,
  21 + ..\core\srs_core_amf0.hpp,
  22 + ..\core\srs_core_amf0.cpp,
  23 + ..\core\srs_core_stream.hpp,
  24 + ..\core\srs_core_stream.cpp,
21 ..\core\srs_core_socket.hpp, 25 ..\core\srs_core_socket.hpp,
22 ..\core\srs_core_socket.cpp, 26 ..\core\srs_core_socket.cpp,
23 ..\core\srs_core_buffer.hpp, 27 ..\core\srs_core_buffer.hpp,