├── extern ├── linux-gcc-x86_64 │ ├── lib │ │ ├── libz.a │ │ ├── libpng.a │ │ ├── libuv.a │ │ ├── libvpx.a │ │ ├── libvpxd.a │ │ ├── libyuv.a │ │ ├── libglfw3.a │ │ ├── libhiredis.a │ │ └── libvideocapture.a │ └── include │ │ ├── videocapture │ │ ├── linux │ │ │ ├── V4L2_Utils.h │ │ │ ├── V4L2_Types.h │ │ │ └── V4L2_Capture.h │ │ ├── Utils.h │ │ ├── win │ │ │ ├── MediaFoundation_Types.h │ │ │ ├── MediaFoundation_Utils.h │ │ │ ├── MediaFoundation_Callback.h │ │ │ └── MediaFoundation_Capture.h │ │ ├── mac │ │ │ ├── AVFoundation_Capture.h │ │ │ └── AVFoundation_Interface.h │ │ ├── Capture.h │ │ └── Base.h │ │ ├── libyuv │ │ ├── version.h │ │ ├── rotate_argb.h │ │ ├── scale_argb.h │ │ ├── compare.h │ │ ├── cpu_id.h │ │ ├── basic_types.h │ │ ├── scale.h │ │ └── rotate.h │ │ ├── libyuv.h │ │ ├── vpx │ │ ├── vpx_integer.h │ │ ├── vpx_frame_buffer.h │ │ └── vp8dx.h │ │ ├── uv-linux.h │ │ └── adapters │ │ ├── libuv.h │ │ └── libevent.h └── mac-clang-x86_64 │ ├── lib │ ├── libz.a │ ├── .DS_Store │ ├── libpng.a │ ├── libuv.a │ ├── libvpx.a │ ├── libyuv.a │ ├── libglfw3.a │ ├── libhiredis.a │ └── libvideocapture.a │ └── include │ ├── .DS_Store │ ├── videocapture │ ├── linux │ │ ├── V4L2_Utils.h │ │ ├── V4L2_Types.h │ │ └── V4L2_Capture.h │ ├── Utils.h │ ├── win │ │ ├── MediaFoundation_Types.h │ │ ├── MediaFoundation_Utils.h │ │ ├── MediaFoundation_Callback.h │ │ └── MediaFoundation_Capture.h │ ├── mac │ │ ├── AVFoundation_Capture.h │ │ └── AVFoundation_Interface.h │ ├── Capture.h │ └── Base.h │ ├── libyuv │ ├── version.h │ ├── rotate_argb.h │ ├── scale_argb.h │ ├── compare.h │ ├── cpu_id.h │ ├── scale.h │ ├── basic_types.h │ └── rotate.h │ ├── libyuv.h │ ├── vpx │ ├── vpx_integer.h │ ├── vpx_frame_buffer.h │ └── vp8dx.h │ ├── uv-bsd.h │ ├── uv-version.h │ ├── uv-linux.h │ ├── uv-sunos.h │ ├── adapters │ ├── libuv.h │ └── libevent.h │ └── uv-darwin.h ├── src ├── examples │ ├── test_rxs_receiver.cpp │ ├── test_rxs_fec.c │ ├── test_rxs_controller.cpp │ ├── test_rxs_stun.c │ ├── test_rxs_packets.c │ ├── test_rxs_sender.cpp │ ├── test_rxs_streamer.cpp │ ├── test_rxs_control.c │ ├── test_rxs_signal_redis.c │ └── test_rxs_jitter.c ├── streamer │ ├── Receiver.cpp │ ├── Socket.cpp │ ├── Buffer.cpp │ ├── SocketUDP.cpp │ └── Controller.cpp └── rxs_streamer │ ├── rxs_decoder.c │ ├── rxs_sender.c │ ├── rxs_receiver.c │ └── rxs_encoder.c ├── .gitignore ├── include ├── rxs_streamer │ ├── rxs_types.h │ ├── rxs_sender.h │ ├── rxs_decoder.h │ ├── rxs_receiver.h │ ├── rxs_signaling.h │ ├── rxs_reconstruct.h │ ├── rxs_encoder.h │ ├── rxs_ivf.h │ ├── rxs_stun_io.h │ ├── rxs_packetizer.h │ ├── rxs_generator.h │ ├── rxs_depacketizer.h │ └── rxs_control.h └── streamer │ ├── Receiver.h │ ├── SocketUDP.h │ ├── Controller.h │ ├── Sender.h │ ├── Socket.h │ └── Buffer.h ├── TODO.md └── README.md /extern/linux-gcc-x86_64/lib/libz.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/linux-gcc-x86_64/lib/libz.a -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/lib/libz.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/mac-clang-x86_64/lib/libz.a -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/lib/libpng.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/linux-gcc-x86_64/lib/libpng.a -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/lib/libuv.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/linux-gcc-x86_64/lib/libuv.a -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/lib/libvpx.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/linux-gcc-x86_64/lib/libvpx.a -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/lib/libvpxd.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/linux-gcc-x86_64/lib/libvpxd.a -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/lib/libyuv.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/linux-gcc-x86_64/lib/libyuv.a -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/lib/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/mac-clang-x86_64/lib/.DS_Store -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/lib/libpng.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/mac-clang-x86_64/lib/libpng.a -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/lib/libuv.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/mac-clang-x86_64/lib/libuv.a -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/lib/libvpx.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/mac-clang-x86_64/lib/libvpx.a -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/lib/libyuv.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/mac-clang-x86_64/lib/libyuv.a -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/lib/libglfw3.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/linux-gcc-x86_64/lib/libglfw3.a -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/lib/libglfw3.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/mac-clang-x86_64/lib/libglfw3.a -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/lib/libhiredis.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/linux-gcc-x86_64/lib/libhiredis.a -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/mac-clang-x86_64/include/.DS_Store -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/lib/libhiredis.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/mac-clang-x86_64/lib/libhiredis.a -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/lib/libvideocapture.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/linux-gcc-x86_64/lib/libvideocapture.a -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/lib/libvideocapture.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diederickh/rxs_streamer/HEAD/extern/mac-clang-x86_64/lib/libvideocapture.a -------------------------------------------------------------------------------- /src/examples/test_rxs_receiver.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | printf("\n\ntest_rxs_receiver\n\n"); 6 | } 7 | -------------------------------------------------------------------------------- /src/examples/test_rxs_fec.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | printf("\n\ntest_fec\n\n"); 6 | 7 | printf("\n\n"); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/streamer/Receiver.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace rxs { 4 | 5 | Receiver::Reciever(std::string rip, uint16_t rport) 6 | :rip(rip) 7 | ,rport(rport) 8 | { 9 | 10 | } 11 | 12 | 13 | } /* namespace rxs */ 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Libraries 8 | *.lib 9 | *.a 10 | 11 | # Shared objects (inc. Windows DLLs) 12 | *.dll 13 | *.so 14 | *.so.* 15 | *.dylib 16 | 17 | # Executables 18 | *.exe 19 | *.out 20 | *.app 21 | *.i*86 22 | *.x86_64 23 | *.hex 24 | 25 | LOGBOOK.org -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/linux/V4L2_Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_CAPTURE_V4L2_UTILS_H 2 | #define VIDEO_CAPTURE_V4L2_UTILS_H 3 | 4 | extern "C" { 5 | # include 6 | } 7 | 8 | namespace ca { 9 | 10 | int capture_format_to_v4l2_pixel_format(int fmt); 11 | int v4l2_pixel_format_to_capture_format(int fmt); 12 | std::string v4l2_pixel_format_to_string(int fmt); 13 | 14 | }; // namespace ca 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/linux/V4L2_Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_CAPTURE_V4L2_UTILS_H 2 | #define VIDEO_CAPTURE_V4L2_UTILS_H 3 | 4 | extern "C" { 5 | # include 6 | } 7 | 8 | namespace ca { 9 | 10 | int capture_format_to_v4l2_pixel_format(int fmt); 11 | int v4l2_pixel_format_to_capture_format(int fmt); 12 | std::string v4l2_pixel_format_to_string(int fmt); 13 | 14 | }; // namespace ca 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_types.h: -------------------------------------------------------------------------------- 1 | #ifndef RXS_TYPES_H 2 | #define RXS_TYPES_H 3 | 4 | //#define RXS_RTP_PAYLOAD_SIZE 16371 5 | #define RXS_RTP_PAYLOAD_SIZE 700 /* max bytes of a udp packet */ 6 | //#define RXS_RTP_PAYLOAD_SIZE 1010 7 | #define RXS_CONTROL_PORT 5544 /* default control port */ 8 | #define RXS_MAX_MISSING_PACKETS 15 9 | #define RXS_MAX_SPLIT_PACKETS 8 /* over how many rtp packets one VP8 frame can be split */ 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_CAPTURE_UTILS_H 2 | #define VIDEO_CAPTURE_UTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace ca { 10 | 11 | int fps_from_rational(uint64_t num, uint64_t den); /* Converts a rational value to one of the CA_FPS_* values defined in Types.h */ 12 | std::string format_to_string(int fmt); 13 | 14 | }; // namespace ca 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_CAPTURE_UTILS_H 2 | #define VIDEO_CAPTURE_UTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace ca { 10 | 11 | int fps_from_rational(uint64_t num, uint64_t den); /* Converts a rational value to one of the CA_FPS_* values defined in Types.h */ 12 | std::string format_to_string(int fmt); 13 | 14 | }; // namespace ca 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_sender.h: -------------------------------------------------------------------------------- 1 | /* 2 | rxs_sender 3 | ----------- 4 | 5 | */ 6 | 7 | #ifndef RXS_SENDER_H 8 | #define RXS_SENDER_H 9 | 10 | #include 11 | 12 | typedef struct rxs_sender rxs_sender; 13 | 14 | struct rxs_sender { 15 | struct sockaddr_in saddr; 16 | uv_udp_t send_sock; 17 | uv_loop_t* loop; 18 | }; 19 | 20 | int rxs_sender_init(rxs_sender* net, const char* ip, int port); 21 | int rxs_sender_send(rxs_sender* net, uint8_t* buffer, uint32_t nbytes); 22 | void rxs_sender_update(rxs_sender* net); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/win/MediaFoundation_Types.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_CAPTURE_MEDIA_FOUNDATION_TYPES_H 2 | #define VIDEO_CAPTURE_MEDIA_FOUNDATION_TYPES_H 3 | 4 | namespace ca { 5 | 6 | /* -------------------------------------- */ 7 | 8 | class MediaFoundation_Device { /* Wrapper around a Media Foundation device */ 9 | public: 10 | MediaFoundation_Device(); 11 | ~MediaFoundation_Device(); 12 | void clear(); 13 | }; 14 | 15 | 16 | } // namespace ca 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/win/MediaFoundation_Types.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_CAPTURE_MEDIA_FOUNDATION_TYPES_H 2 | #define VIDEO_CAPTURE_MEDIA_FOUNDATION_TYPES_H 3 | 4 | namespace ca { 5 | 6 | /* -------------------------------------- */ 7 | 8 | class MediaFoundation_Device { /* Wrapper around a Media Foundation device */ 9 | public: 10 | MediaFoundation_Device(); 11 | ~MediaFoundation_Device(); 12 | void clear(); 13 | }; 14 | 15 | 16 | } // namespace ca 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/streamer/Receiver.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAMER_RECEIVER_H 2 | #define STREAMER_RECEIVER_H 3 | 4 | #include 5 | #include 6 | 7 | namespace rxs { 8 | 9 | class Receiver { 10 | 11 | public: 12 | Receiver(std::string ip, uint16_t port); 13 | ~Receiver(); 14 | int start(); 15 | int stop(); 16 | 17 | public: 18 | Loop loop; 19 | SocketUDP sock; 20 | std::string rip; /* remote IP */ 21 | uint16_t rport; /* remote port */ 22 | }; 23 | 24 | } /* namespace rxs */ 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/libyuv/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_VERSION_H_ 13 | 14 | #define LIBYUV_VERSION 1007 15 | 16 | #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT 17 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/libyuv/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_VERSION_H_ 13 | 14 | #define LIBYUV_VERSION 905 15 | 16 | #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT 17 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_decoder.h: -------------------------------------------------------------------------------- 1 | #ifndef RXS_DECODER_H 2 | #define RXS_DECODER_H 3 | 4 | #define VPX_CODEC_DISABLE_COMPAT 1 5 | #include 6 | #include 7 | #include 8 | #define vpx_dx_interface (vpx_codec_vp8_dx()) 9 | 10 | typedef struct rxs_decoder rxs_decoder; 11 | typedef void(*rxs_decoder_callback)(rxs_decoder* dec, vpx_image_t* img); 12 | 13 | struct rxs_decoder { 14 | vpx_codec_ctx_t ctx; 15 | vpx_image_t* img; 16 | void* user; 17 | rxs_decoder_callback on_image; 18 | }; 19 | 20 | int rxs_decoder_init(rxs_decoder* dec); 21 | int rxs_decoder_clear(rxs_decoder* dec); 22 | int rxs_decoder_decode(rxs_decoder* dec, uint8_t* buffer, uint32_t nbytes); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/examples/test_rxs_controller.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | static void sig(int s); 8 | 9 | bool must_run = true; 10 | 11 | int main() { 12 | 13 | printf("\n\ntest_controller\n\n"); 14 | 15 | signal(SIGINT, sig); 16 | 17 | rxs::Controller controller("127.0.0.1", 6688); 18 | if (0 != controller.init()) { 19 | exit(1); 20 | } 21 | 22 | controller.addRemote("127.0.0.1", 7000); 23 | controller.addRemote("127.0.0.1", 7001); 24 | controller.addRemote("127.0.0.1", 7002); 25 | controller.addRemote("127.0.0.1", 7003); 26 | 27 | while(must_run) { 28 | controller.update(); 29 | } 30 | 31 | return 0; 32 | } 33 | 34 | static void sig(int s) { 35 | printf("Sig handler.\n"); 36 | must_run = false; 37 | } 38 | -------------------------------------------------------------------------------- /include/streamer/SocketUDP.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAMER_SOCKET_UDP_H 2 | #define STREAMER_SOCKET_UDP_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace rxs { 11 | 12 | class SocketUDP : public Socket { 13 | 14 | public: 15 | SocketUDP(Loop* loop, size_t buffersize = 8192); 16 | ~SocketUDP(); 17 | int bind(std::string ip, uint16_t port); 18 | int getSocketDescriptor(); 19 | int sendTo(std::string ip, uint16_t port, const uint8_t* data, uint32_t nbytes, socket_on_write onwritten, void* udata); 20 | 21 | public: 22 | struct sockaddr_in addr; 23 | int sock; 24 | std::string ip; 25 | uint16_t port; 26 | }; 27 | 28 | inline int SocketUDP::getSocketDescriptor() { 29 | return sock; 30 | } 31 | 32 | } /* namespace rxs */ 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/examples/test_rxs_stun.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | static void sigh(int s); 7 | static void on_address(rxs_stun_io* io, struct sockaddr_in* addr); 8 | 9 | rxs_stun_io stun_io; 10 | 11 | int main() { 12 | printf("\n\ntest_stun\n\n"); 13 | 14 | signal(SIGINT, sigh); 15 | 16 | if (rxs_stun_io_init(&stun_io, "stun.l.google.com", "19302") < 0) { 17 | printf("Error: cannot init stun io.\n"); 18 | exit(1); 19 | } 20 | 21 | stun_io.on_address = on_address; 22 | 23 | while(1) { 24 | rxs_stun_io_update(&stun_io); 25 | } 26 | 27 | printf("\n"); 28 | return 0; 29 | } 30 | 31 | static void sigh(int s) { 32 | printf("\n\nSIGNALLED!\n\n"); 33 | exit(0); 34 | } 35 | 36 | 37 | static void on_address(rxs_stun_io* io, struct sockaddr_in* addr) { 38 | printf("Got an address: %04X:%d.\n", addr->sin_addr.s_addr, addr->sin_port); 39 | } 40 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/libyuv/rotate_argb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_ROTATE_ARGB_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_ROTATE_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/rotate.h" // For RotationMode. 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | // Rotate ARGB frame 23 | LIBYUV_API 24 | int ARGBRotate(const uint8* src_argb, int src_stride_argb, 25 | uint8* dst_argb, int dst_stride_argb, 26 | int src_width, int src_height, enum RotationMode mode); 27 | 28 | #ifdef __cplusplus 29 | } // extern "C" 30 | } // namespace libyuv 31 | #endif 32 | 33 | #endif // INCLUDE_LIBYUV_ROTATE_ARGB_H_ NOLINT 34 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/libyuv/rotate_argb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_ROTATE_ARGB_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_ROTATE_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/rotate.h" // For RotationMode. 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | // Rotate ARGB frame 23 | LIBYUV_API 24 | int ARGBRotate(const uint8* src_argb, int src_stride_argb, 25 | uint8* dst_argb, int dst_stride_argb, 26 | int src_width, int src_height, enum RotationMode mode); 27 | 28 | #ifdef __cplusplus 29 | } // extern "C" 30 | } // namespace libyuv 31 | #endif 32 | 33 | #endif // INCLUDE_LIBYUV_ROTATE_ARGB_H_ NOLINT 34 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/mac/AVFoundation_Capture.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | AVFoundation_Capture 4 | ------------- 5 | 6 | Grabbing on Mac using AVFoundation. 7 | 8 | 9 | */ 10 | #ifndef VIDEO_CAPTURE_AV_FOUNDATION_H 11 | #define VIDEO_CAPTURE_AV_FOUNDATION_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace ca { 19 | 20 | class AVFoundation_Capture : public Base { 21 | 22 | public: 23 | AVFoundation_Capture(frame_callback fc, void* user); 24 | ~AVFoundation_Capture(); 25 | 26 | /* Interface */ 27 | int open(Settings settings); 28 | int close(); 29 | int start(); 30 | int stop(); 31 | void update(); 32 | 33 | /* Capabilities */ 34 | std::vector getCapabilities(int device); 35 | std::vector getDevices(); 36 | std::vector getOutputFormats(); 37 | 38 | private: 39 | void* cap; /* The AVFoundation_Implementation interface */ 40 | }; 41 | 42 | }; // namespace ca 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/mac/AVFoundation_Capture.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | AVFoundation_Capture 4 | ------------- 5 | 6 | Grabbing on Mac using AVFoundation. 7 | 8 | 9 | */ 10 | #ifndef VIDEO_CAPTURE_AV_FOUNDATION_H 11 | #define VIDEO_CAPTURE_AV_FOUNDATION_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace ca { 19 | 20 | class AVFoundation_Capture : public Base { 21 | 22 | public: 23 | AVFoundation_Capture(frame_callback fc, void* user); 24 | ~AVFoundation_Capture(); 25 | 26 | /* Interface */ 27 | int open(Settings settings); 28 | int close(); 29 | int start(); 30 | int stop(); 31 | void update(); 32 | 33 | /* Capabilities */ 34 | std::vector getCapabilities(int device); 35 | std::vector getDevices(); 36 | std::vector getOutputFormats(); 37 | 38 | private: 39 | void* cap; /* The AVFoundation_Implementation interface */ 40 | }; 41 | 42 | }; // namespace ca 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/libyuv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/compare.h" 16 | #include "libyuv/convert.h" 17 | #include "libyuv/convert_argb.h" 18 | #include "libyuv/convert_from.h" 19 | #include "libyuv/convert_from_argb.h" 20 | #include "libyuv/cpu_id.h" 21 | #include "libyuv/format_conversion.h" 22 | #include "libyuv/mjpeg_decoder.h" 23 | #include "libyuv/planar_functions.h" 24 | #include "libyuv/rotate.h" 25 | #include "libyuv/rotate_argb.h" 26 | #include "libyuv/row.h" 27 | #include "libyuv/scale.h" 28 | #include "libyuv/scale_argb.h" 29 | #include "libyuv/version.h" 30 | #include "libyuv/video_common.h" 31 | 32 | #endif // INCLUDE_LIBYUV_H_ NOLINT 33 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/libyuv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/compare.h" 16 | #include "libyuv/convert.h" 17 | #include "libyuv/convert_argb.h" 18 | #include "libyuv/convert_from.h" 19 | #include "libyuv/convert_from_argb.h" 20 | #include "libyuv/cpu_id.h" 21 | #include "libyuv/format_conversion.h" 22 | #include "libyuv/mjpeg_decoder.h" 23 | #include "libyuv/planar_functions.h" 24 | #include "libyuv/rotate.h" 25 | #include "libyuv/rotate_argb.h" 26 | #include "libyuv/row.h" 27 | #include "libyuv/scale.h" 28 | #include "libyuv/scale_argb.h" 29 | #include "libyuv/scale_row.h" 30 | #include "libyuv/version.h" 31 | #include "libyuv/video_common.h" 32 | 33 | #endif // INCLUDE_LIBYUV_H_ NOLINT 34 | -------------------------------------------------------------------------------- /src/examples/test_rxs_packets.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define FAKE_SIZE (1024 * 1024) 8 | 9 | int main() { 10 | printf("\n\ntest_packets.\n\n"); 11 | 12 | int i; 13 | rxs_packet* pkt; 14 | rxs_packets ps; 15 | uint8_t* fake_data; 16 | 17 | if (!rxs_packets_init(&ps, 10, FAKE_SIZE) < 0) { 18 | printf("Error: cannot create the packets buffer.\n"); 19 | exit(1); 20 | } 21 | 22 | fake_data = (uint8_t*)malloc(FAKE_SIZE); 23 | if (!fake_data) { 24 | printf("Error: out of mem, cannot alloc tmp buffer.\n"); 25 | exit(1); 26 | } 27 | 28 | for (i = 0; i < 15; ++i) { 29 | printf("Writing into a packet: %p, %u bytes\n", pkt->data, FAKE_SIZE); 30 | if (rxs_packets_write(&ps, fake_data, sizeof(fake_data)) < 0) { 31 | printf("Error: cannot write to packet.\n"); 32 | } 33 | else { 34 | printf("Wrote some fake data.\n"); 35 | } 36 | printf("-\n"); 37 | } 38 | 39 | free(fake_data); 40 | fake_data = NULL; 41 | 42 | if (rxs_packets_clear(&ps) < 0) { 43 | printf("Error: cannot clear the packet buffer. Leaking here.\n"); 44 | exit(1); 45 | } 46 | 47 | printf("\n\n"); 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_receiver.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | rxs_receiver 4 | ------------ 5 | 6 | Used to receive UDP RTP packets that contain VP8. 7 | 8 | 9 | 10 | rxs_receiver rec; 11 | static void on_data(rxs_receiver* rec, uint8_t* buf, uint32_t nbytes); 12 | 13 | int main() { 14 | 15 | rxs_receiver_init(&rec, 6790); 16 | 17 | rec.on_data = on_data; 18 | 19 | while(1) { 20 | rxs_receiver_update(&rec); 21 | } 22 | } 23 | 24 | static void on_data(rxs_receiver* rec, uint8_t* buf, uint32_t nbytes) { 25 | } 26 | 27 | 28 | */ 29 | #ifndef RXS_RECEIVER_H 30 | #define RXS_RECEIVER_H 31 | 32 | #include 33 | 34 | typedef struct rxs_receiver rxs_receiver; 35 | typedef void(*rxs_receiver_callback)(rxs_receiver* rec, uint8_t* buf, uint32_t nbytes); 36 | 37 | struct rxs_receiver { 38 | 39 | /* networking */ 40 | struct sockaddr_in saddr; 41 | uv_udp_t recv_sock; 42 | uv_loop_t* loop; 43 | 44 | /* callback */ 45 | void* user; 46 | rxs_receiver_callback on_data; /* will be called when we receive data */ 47 | }; 48 | 49 | int rxs_receiver_init(rxs_receiver* r, int port); 50 | void rxs_receiver_update(rxs_receiver* r); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/examples/test_rxs_sender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | static void sig(int s); 9 | 10 | bool must_run = true; 11 | 12 | int main() { 13 | 14 | signal(SIGINT, sig); 15 | 16 | rxs::Sender sender("127.0.0.1", 6677, "127.0.0.1", 6688); 17 | if (0 != sender.init()) { 18 | exit(1); 19 | } 20 | 21 | std::string test_data = "test data"; 22 | 23 | while(must_run) { 24 | 25 | /* Get a free chunk, add some test data to it and give it back to the sender so it's send. */ 26 | rxs::Chunk* c = sender.getFreeChunk(); 27 | if (NULL != c) { 28 | 29 | /* Make sure the buffer is reset before we write new data into it. */ 30 | c->clear(); 31 | 32 | /* Copy data */ 33 | std::copy(test_data.begin(), test_data.end(), std::back_inserter(c->data)); 34 | 35 | /* Give our chunk to the sender which will make sure it's delivere to the remote ip:port */ 36 | sender.sendChunk(c); 37 | 38 | printf("Size of chunk: %lu\n", c->size()); 39 | } 40 | 41 | usleep(100000); 42 | } 43 | 44 | sender.shutdown(); 45 | 46 | return 0; 47 | } 48 | 49 | static void sig(int s) { 50 | printf("Sig handler.\n"); 51 | must_run = false; 52 | } 53 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/linux/V4L2_Types.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_CAPTURE_V4L2_TYPES_H 2 | #define VIDEO_CAPTURE_V4L2_TYPES_H 3 | 4 | #include 5 | 6 | namespace ca { 7 | 8 | /* -------------------------------------- */ 9 | 10 | class V4L2_Buffer { /* A V4L2_Buffer is used to store the frames of the camera */ 11 | public: 12 | V4L2_Buffer(); 13 | ~V4L2_Buffer(); 14 | void clear(); /* Sets the buffer to NULL and size to 0. IMPORTANT: we do not free any allocated memory; the user of this buffer should do that! */ 15 | 16 | public: 17 | void* start; 18 | size_t length; 19 | }; 20 | 21 | /* -------------------------------------- */ 22 | 23 | class V4L2_Device { /* Represents a V4L2 device */ 24 | public: 25 | V4L2_Device(); 26 | ~V4L2_Device(); 27 | void clear(); 28 | std::string toString(); 29 | 30 | public: 31 | std::string path; 32 | std::string id_vendor; 33 | std::string id_product; 34 | std::string driver; 35 | std::string card; 36 | std::string bus_info; 37 | int version_major; 38 | int version_minor; 39 | int version_micro; 40 | }; 41 | 42 | } // namespace ca 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/linux/V4L2_Types.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_CAPTURE_V4L2_TYPES_H 2 | #define VIDEO_CAPTURE_V4L2_TYPES_H 3 | 4 | #include 5 | 6 | namespace ca { 7 | 8 | /* -------------------------------------- */ 9 | 10 | class V4L2_Buffer { /* A V4L2_Buffer is used to store the frames of the camera */ 11 | public: 12 | V4L2_Buffer(); 13 | ~V4L2_Buffer(); 14 | void clear(); /* Sets the buffer to NULL and size to 0. IMPORTANT: we do not free any allocated memory; the user of this buffer should do that! */ 15 | 16 | public: 17 | void* start; 18 | size_t length; 19 | }; 20 | 21 | /* -------------------------------------- */ 22 | 23 | class V4L2_Device { /* Represents a V4L2 device */ 24 | public: 25 | V4L2_Device(); 26 | ~V4L2_Device(); 27 | void clear(); 28 | std::string toString(); 29 | 30 | public: 31 | std::string path; 32 | std::string id_vendor; 33 | std::string id_product; 34 | std::string driver; 35 | std::string card; 36 | std::string bus_info; 37 | int version_major; 38 | int version_minor; 39 | int version_micro; 40 | }; 41 | 42 | } // namespace ca 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /include/streamer/Controller.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Controller 4 | ---------- 5 | 6 | A controller takes care of receiving data on it's port and sending 7 | it to all the added remotes; nothing more than a basic proxy. In the 8 | future we can add more special features. 9 | 10 | You bind the controller to a specific port, then add the remotes that 11 | you want to be able to receive the data. 12 | 13 | 14 | */ 15 | #ifndef STREAMER_CONTROLLER_H 16 | #define STREAMER_CONTROLLER_H 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | namespace rxs { 23 | 24 | /* -------------------------------------------------------------------------- */ 25 | 26 | struct Remote { 27 | std::string ip; 28 | uint16_t port; 29 | }; 30 | 31 | /* -------------------------------------------------------------------------- */ 32 | 33 | class Controller { 34 | 35 | public: 36 | Controller(std::string ip, uint16_t port); 37 | ~Controller(); 38 | int init(); 39 | void update(); 40 | void addRemote(std::string rip, uint16_t port); 41 | 42 | public: 43 | std::string ip; 44 | uint16_t port; 45 | Loop loop; 46 | SocketUDP sock; 47 | std::vector remotes; 48 | }; 49 | 50 | } /* namespace rxs */ 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | general 4 | ------- 5 | - make user of a generic rxs_packet to represent a VP8 packet. 6 | - detect the MTU size dynamically 7 | 8 | rxs_packetizer 9 | -------------- 10 | - The buffer member is way to big then necessary at this moment. 11 | 12 | 13 | rxs_depacketizer 14 | ---------------- 15 | - The depacketizer needs to implement a jitter buffer and 16 | add the code to correctly construct a receive frame from 17 | multiple packets (and ofc. checking for lost packets). 18 | 19 | 20 | rxs_control 21 | ----------- 22 | - Better send buffer management (shouldn't allocate on heap 23 | for commands, see note at control_sender_send. ) 24 | - Implement rxs_control_clear() to shutdown / free mem. 25 | 26 | 27 | rxs_jitter 28 | ---------- 29 | - Implement a rxs_jitter_clear() that deallocates the buffer + packets. 30 | 31 | 32 | rxs_encoder 33 | ----------- 34 | - Implement rxs_encoder_clear() to deallocate memory. 35 | 36 | 37 | rxs_reconstruct 38 | ---------------- 39 | - The number of frames that are keps in the packets buffer should 40 | be optional (also for rxs_jitter). 41 | - See the note about the timestamp in rxs_reconstruct.c 42 | 43 | rxs_stun 44 | -------- 45 | - The static buffer readers (u32, u16) should be similar in how 46 | they are used. Now reading moves the pointer, writing not. Both 47 | need to manipulate the pointer. 48 | - Implement keep alive bindings (search for "seconds" in the 49 | 5389 RFC, it's stated that the server needs to keep info for 50 | 40s). 51 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_signaling.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | signaling 4 | --------- 5 | 6 | Simple signaling client/server model that can be used together 7 | with rxs_stun to exchange the information about the port mappings 8 | which have been made. This file contains both a server and client 9 | implementation on top of picomsg. 10 | 11 | The user who wants to receive video, needs to make sure that 12 | the ports are correctly mapped using STUN. Once there are some 13 | mapped ports, the receiver will notify the signal server about what 14 | port and IP address can be used by the sender. 15 | 16 | */ 17 | #ifndef RXS_SIGNALING_H 18 | #define RXS_SIGNALING_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include /* redis */ 26 | #include /* redis */ 27 | #include /* redis */ 28 | 29 | typedef struct rxs_signal rxs_signal; 30 | 31 | typedef void(*rxs_signal_cb)(rxs_signal* s, char* ip, uint16_t port); 32 | 33 | struct rxs_signal { 34 | redisAsyncContext* redis; 35 | uv_loop_t* loop; 36 | int slot; 37 | void* user; 38 | rxs_signal_cb on_address; 39 | int connected; 40 | }; 41 | 42 | int rxs_signal_init(rxs_signal* s, const char* ip, uint16_t port); 43 | int rxs_signal_subscribe(rxs_signal* s, int slot); 44 | int rxs_signal_update(rxs_signal* s); 45 | int rxs_signal_store_address(rxs_signal* s, int slot, const char* ip, uint16_t port); 46 | int rxs_signal_retrieve_address(rxs_signal* s, int slot); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/streamer/Socket.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | namespace rxs { 7 | 8 | Socket::Socket(Loop* loop, size_t buffersize) 9 | :in_dx(0) 10 | ,on_read(NULL) 11 | ,user(NULL) 12 | ,loop(loop) 13 | ,in_capacity(buffersize) 14 | ,type(SOCKET_TYPE_NONE) 15 | { 16 | 17 | in_buffer = new uint8_t[buffersize]; 18 | if (NULL == in_buffer) { 19 | printf("Error: socket cannot allocate the input buffer. Out of mem?\n"); 20 | exit(1); 21 | } 22 | 23 | if (NULL == loop) { 24 | printf("Error: created socket with a invalid loop!\n"); 25 | exit(1); 26 | } 27 | } 28 | 29 | Socket::~Socket() { 30 | 31 | if (NULL != in_buffer) { 32 | delete[] in_buffer; 33 | in_buffer = NULL; 34 | } 35 | 36 | in_dx = 0; 37 | in_capacity = 0; 38 | user = NULL; 39 | on_read = NULL; 40 | } 41 | 42 | 43 | bool Socket::growInputBuffer() { 44 | 45 | /* duplicate the size. */ 46 | uint8_t* new_buffer = (uint8_t*)realloc(in_buffer, in_capacity * 2); 47 | if (NULL == new_buffer) { 48 | printf("Error: cannot reallocate the input buffer. Make sure you use it read bytes and reset in_dx of your socket.\n"); 49 | return false; 50 | } 51 | 52 | in_buffer = new_buffer; 53 | in_capacity = in_capacity * 2; 54 | 55 | printf("Verbose: we've grown the input buffer for the socket to a size of: %u bytes.\n", in_capacity); 56 | return true; 57 | } 58 | 59 | } /* namespace rxs */ 60 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/win/MediaFoundation_Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_CAPTURE_MEDIA_FOUNDATION_UTILS_H 2 | #define VIDEO_CAPTURE_MEDIA_FOUNDATION_UTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include /* e.g. MFEnumDeviceSources */ 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace ca { 18 | 19 | std::string media_foundation_video_format_to_string(const GUID& guid); /* Convert a MF format to a string */ 20 | int media_foundation_video_format_to_capture_format(GUID guid); /* Convert a MF format to a capture format */ 21 | 22 | // Convert a WCHAR to a std::string 23 | template 24 | T string_cast( const wchar_t* src, unsigned int codePage = CP_ACP) { 25 | 26 | assert(src != 0); 27 | size_t source_length = std::wcslen(src); 28 | 29 | if(source_length > 0) { 30 | 31 | int length = ::WideCharToMultiByte(codePage, 0, src, (int)source_length, NULL, 0, NULL, NULL); 32 | if(length == 0) { 33 | return T(); 34 | } 35 | 36 | std::vector buffer( length ); 37 | ::WideCharToMultiByte(codePage, 0, src, (int)source_length, &buffer[0], length, NULL, NULL); 38 | 39 | return T(buffer.begin(), buffer.end()); 40 | } 41 | else { 42 | return T(); 43 | } 44 | } 45 | 46 | } // namespace ca 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/win/MediaFoundation_Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_CAPTURE_MEDIA_FOUNDATION_UTILS_H 2 | #define VIDEO_CAPTURE_MEDIA_FOUNDATION_UTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include /* e.g. MFEnumDeviceSources */ 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace ca { 18 | 19 | std::string media_foundation_video_format_to_string(const GUID& guid); /* Convert a MF format to a string */ 20 | int media_foundation_video_format_to_capture_format(GUID guid); /* Convert a MF format to a capture format */ 21 | 22 | // Convert a WCHAR to a std::string 23 | template 24 | T string_cast( const wchar_t* src, unsigned int codePage = CP_ACP) { 25 | 26 | assert(src != 0); 27 | size_t source_length = std::wcslen(src); 28 | 29 | if(source_length > 0) { 30 | 31 | int length = ::WideCharToMultiByte(codePage, 0, src, (int)source_length, NULL, 0, NULL, NULL); 32 | if(length == 0) { 33 | return T(); 34 | } 35 | 36 | std::vector buffer( length ); 37 | ::WideCharToMultiByte(codePage, 0, src, (int)source_length, &buffer[0], length, NULL, NULL); 38 | 39 | return T(buffer.begin(), buffer.end()); 40 | } 41 | else { 42 | return T(); 43 | } 44 | } 45 | 46 | } // namespace ca 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/rxs_streamer/rxs_decoder.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int rxs_decoder_init(rxs_decoder* dec) { 7 | 8 | vpx_codec_err_t err; 9 | 10 | if (!dec) { return -1; } 11 | 12 | err = vpx_codec_dec_init(&dec->ctx, vpx_dx_interface, NULL, 0); 13 | if (err) { 14 | printf("Error: cannot initialize the decoder: %s.\n", vpx_codec_err_to_string(err)); 15 | return -2; 16 | } 17 | 18 | dec->img = NULL; 19 | 20 | return 0; 21 | } 22 | 23 | /* 24 | 25 | Decode the given data. Note that on linux libvpx 26 | will crash at this moment when the first partition 27 | you pass into this function is not a key frame. 28 | 29 | */ 30 | int rxs_decoder_decode(rxs_decoder* dec, uint8_t* buffer, uint32_t nbytes) { 31 | 32 | vpx_codec_iter_t iter = NULL; 33 | vpx_codec_err_t err; 34 | 35 | if (!dec) { return -1; } 36 | if (!buffer) { return -2; } 37 | if (!nbytes) { return -3; } 38 | 39 | dec->img = NULL; 40 | 41 | err = vpx_codec_decode(&dec->ctx, buffer, nbytes, NULL, 0); 42 | if (err) { 43 | printf("Error: cannot decode buffer: %s\n", vpx_codec_err_to_string(err)); 44 | return -4; 45 | } 46 | 47 | while ( (dec->img = vpx_codec_get_frame(&dec->ctx, &iter)) ) { 48 | dec->on_image(dec, dec->img); 49 | } 50 | 51 | return 0; 52 | } 53 | 54 | int rxs_decoder_clear(rxs_decoder* dec) { 55 | 56 | if (!dec) { return -1; } 57 | 58 | if (vpx_codec_destroy(&dec->ctx)) { 59 | printf("Error: cannot destroy the decoder.\n"); 60 | return -2; 61 | } 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /include/streamer/Sender.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Sender 4 | ----- 5 | 6 | Sender is used to push media data to the Controller. It wraps 7 | around the Loop/Socket/etc.. to make it easy for the user to 8 | push data. 9 | 10 | */ 11 | 12 | #ifndef STREAMER_SENDER_H 13 | #define STREAMER_SENDER_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | namespace rxs { 24 | 25 | class Sender { 26 | 27 | public: 28 | Sender(std::string lip, uint16_t lport, std::string rip, uint16_t rport); /* lip = local ip, lport = local port, rip = remote IP, rport = remote port to which we send data. */ 29 | ~Sender(); 30 | int init(); 31 | void shutdown(); 32 | void update(); 33 | void lock(); 34 | void unlock(); 35 | Chunk* getFreeChunk(); 36 | void sendChunk(Chunk* c); 37 | 38 | public: 39 | Buffer buffer; /* our output buffer, contains the chunks we can send. */ 40 | Loop loop; 41 | SocketUDP sock; 42 | bool is_running; 43 | std::string rip; 44 | std::string lip; 45 | uint16_t rport; 46 | uint16_t lport; 47 | bool must_stop; 48 | pthread_t thread; 49 | pthread_mutex_t mutex; 50 | pthread_cond_t cond; 51 | }; 52 | 53 | inline void Sender::lock() { 54 | pthread_mutex_lock(&mutex); 55 | } 56 | 57 | inline void Sender::unlock() { 58 | pthread_mutex_unlock(&mutex); 59 | } 60 | 61 | } /* namespace rxs */ 62 | #endif 63 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/win/MediaFoundation_Callback.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Asynchronous Source Reader 4 | --------------------------- 5 | See http://msdn.microsoft.com/en-us/library/windows/desktop/gg583871(v=vs.85).aspx for more information. 6 | 7 | */ 8 | #ifndef VIDEO_CAPTURE_MEDIA_FOUNDATION_CALLBACK_H 9 | #define VIDEO_CAPTURE_MEDIA_FOUNDATION_CALLBACK_H 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace ca { 17 | 18 | class MediaFoundation_Capture; 19 | 20 | class MediaFoundation_Callback : public IMFSourceReaderCallback { 21 | public: 22 | static bool createInstance(MediaFoundation_Capture* cap, MediaFoundation_Callback** cb); 23 | 24 | STDMETHODIMP QueryInterface(REFIID iid, void** v); 25 | STDMETHODIMP_(ULONG) AddRef(); 26 | STDMETHODIMP_(ULONG) Release(); 27 | 28 | STDMETHODIMP OnReadSample(HRESULT hr, DWORD streamIndex, DWORD streamFlags, LONGLONG timestamp, IMFSample* sample); 29 | STDMETHODIMP OnEvent(DWORD streamIndex, IMFMediaEvent* event); 30 | STDMETHODIMP OnFlush(DWORD streamIndex); 31 | 32 | HRESULT Wait(DWORD* streamFlags, LONGLONG* timestamp, IMFSample* sample) { return S_OK; } 33 | HRESULT Cancel() { return S_OK; } 34 | 35 | private: 36 | MediaFoundation_Callback(MediaFoundation_Capture* cap); 37 | virtual ~MediaFoundation_Callback(); 38 | 39 | private: 40 | MediaFoundation_Capture* cap; 41 | long ref_count; 42 | CRITICAL_SECTION crit_sec; 43 | }; 44 | 45 | } // namespace ca 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/win/MediaFoundation_Callback.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Asynchronous Source Reader 4 | --------------------------- 5 | See http://msdn.microsoft.com/en-us/library/windows/desktop/gg583871(v=vs.85).aspx for more information. 6 | 7 | */ 8 | #ifndef VIDEO_CAPTURE_MEDIA_FOUNDATION_CALLBACK_H 9 | #define VIDEO_CAPTURE_MEDIA_FOUNDATION_CALLBACK_H 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace ca { 17 | 18 | class MediaFoundation_Capture; 19 | 20 | class MediaFoundation_Callback : public IMFSourceReaderCallback { 21 | public: 22 | static bool createInstance(MediaFoundation_Capture* cap, MediaFoundation_Callback** cb); 23 | 24 | STDMETHODIMP QueryInterface(REFIID iid, void** v); 25 | STDMETHODIMP_(ULONG) AddRef(); 26 | STDMETHODIMP_(ULONG) Release(); 27 | 28 | STDMETHODIMP OnReadSample(HRESULT hr, DWORD streamIndex, DWORD streamFlags, LONGLONG timestamp, IMFSample* sample); 29 | STDMETHODIMP OnEvent(DWORD streamIndex, IMFMediaEvent* event); 30 | STDMETHODIMP OnFlush(DWORD streamIndex); 31 | 32 | HRESULT Wait(DWORD* streamFlags, LONGLONG* timestamp, IMFSample* sample) { return S_OK; } 33 | HRESULT Cancel() { return S_OK; } 34 | 35 | private: 36 | MediaFoundation_Callback(MediaFoundation_Capture* cap); 37 | virtual ~MediaFoundation_Callback(); 38 | 39 | private: 40 | MediaFoundation_Capture* cap; 41 | long ref_count; 42 | CRITICAL_SECTION crit_sec; 43 | }; 44 | 45 | } // namespace ca 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/vpx/vpx_integer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | #ifndef VPX_VPX_INTEGER_H_ 13 | #define VPX_VPX_INTEGER_H_ 14 | 15 | /* get ptrdiff_t, size_t, wchar_t, NULL */ 16 | #include 17 | 18 | #if (defined(_MSC_VER) && (_MSC_VER < 1600)) || defined(VPX_EMULATE_INTTYPES) 19 | typedef signed char int8_t; 20 | typedef signed short int16_t; 21 | typedef signed int int32_t; 22 | 23 | typedef unsigned char uint8_t; 24 | typedef unsigned short uint16_t; 25 | typedef unsigned int uint32_t; 26 | 27 | #if (defined(_MSC_VER) && (_MSC_VER < 1600)) 28 | typedef signed __int64 int64_t; 29 | typedef unsigned __int64 uint64_t; 30 | #define INT64_MAX _I64_MAX 31 | #define INT16_MAX _I16_MAX 32 | #define INT16_MIN _I16_MIN 33 | #endif 34 | 35 | #ifndef _UINTPTR_T_DEFINED 36 | typedef size_t uintptr_t; 37 | #endif 38 | 39 | #else 40 | 41 | /* Most platforms have the C99 standard integer types. */ 42 | 43 | #if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) 44 | #define __STDC_FORMAT_MACROS 45 | #endif 46 | #include 47 | 48 | #endif 49 | 50 | /* VS2010 defines stdint.h, but not inttypes.h */ 51 | #if defined(_MSC_VER) && _MSC_VER < 1800 52 | #define PRId64 "I64d" 53 | #else 54 | #include 55 | #endif 56 | 57 | #endif // VPX_VPX_INTEGER_H_ 58 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/vpx/vpx_integer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | #ifndef VPX_VPX_INTEGER_H_ 13 | #define VPX_VPX_INTEGER_H_ 14 | 15 | /* get ptrdiff_t, size_t, wchar_t, NULL */ 16 | #include 17 | 18 | #if (defined(_MSC_VER) && (_MSC_VER < 1600)) || defined(VPX_EMULATE_INTTYPES) 19 | typedef signed char int8_t; 20 | typedef signed short int16_t; 21 | typedef signed int int32_t; 22 | 23 | typedef unsigned char uint8_t; 24 | typedef unsigned short uint16_t; 25 | typedef unsigned int uint32_t; 26 | 27 | #if (defined(_MSC_VER) && (_MSC_VER < 1600)) 28 | typedef signed __int64 int64_t; 29 | typedef unsigned __int64 uint64_t; 30 | #define INT64_MAX _I64_MAX 31 | #define INT16_MAX _I16_MAX 32 | #define INT16_MIN _I16_MIN 33 | #endif 34 | 35 | #ifndef _UINTPTR_T_DEFINED 36 | typedef size_t uintptr_t; 37 | #endif 38 | 39 | #else 40 | 41 | /* Most platforms have the C99 standard integer types. */ 42 | 43 | #if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) 44 | #define __STDC_FORMAT_MACROS 45 | #endif 46 | #include 47 | 48 | #endif 49 | 50 | /* VS2010 defines stdint.h, but not inttypes.h */ 51 | #if defined(_MSC_VER) && _MSC_VER < 1800 52 | #define PRId64 "I64d" 53 | #else 54 | #include 55 | #endif 56 | 57 | #endif // VPX_VPX_INTEGER_H_ 58 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/uv-bsd.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_BSD_H 23 | #define UV_BSD_H 24 | 25 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 26 | uv__io_t event_watcher; \ 27 | 28 | #define UV_IO_PRIVATE_PLATFORM_FIELDS \ 29 | int rcount; \ 30 | int wcount; \ 31 | 32 | #define UV_HAVE_KQUEUE 1 33 | 34 | #endif /* UV_BSD_H */ 35 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/uv-version.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_VERSION_H 23 | #define UV_VERSION_H 24 | 25 | /* 26 | * Versions with an even minor version (e.g. 0.6.1 or 1.0.4) are API and ABI 27 | * stable. When the minor version is odd, the API can change between patch 28 | * releases. Make sure you update the -soname directives in configure.ac 29 | * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but 30 | * not UV_VERSION_PATCH.) 31 | */ 32 | 33 | #define UV_VERSION_MAJOR 0 34 | #define UV_VERSION_MINOR 11 35 | #define UV_VERSION_PATCH 26 36 | #define UV_VERSION_IS_RELEASE 0 37 | 38 | #endif /* UV_VERSION_H */ 39 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/mac/AVFoundation_Interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | C-Interface for the AVFoundation webcam grabber. 4 | 5 | */ 6 | #ifndef VIDEO_CAPTURE_AV_FOUNDATION_INTERFACE_H 7 | #define VIDEO_CAPTURE_AV_FOUNDATION_INTERFACE_H 8 | 9 | #include 10 | #include 11 | 12 | void* ca_av_alloc(); /* Allocate the AVFoundation implementation. */ 13 | void ca_av_dealloc(void* cap); /* Deallocate the AVFoundation implementation */ 14 | int ca_av_get_devices(void* cap, std::vector& result); /* Get available devices. */ 15 | int ca_av_get_capabilities(void* cap, int device, std::vector& result); /* Get capabilities. */ 16 | int ca_av_get_output_formats(void* cap, std::vector& result); /* The AVFoundation frameworks allows conversion of the raw input samples it gets from a webcam into a couple of other output formats. This is not supported by all implementations though. This function returns the formats which are supported. */ 17 | int ca_av_open(void* cap, ca::Settings settings); /* Opens the given capture device with the given settings object. */ 18 | int ca_av_close(void* cap); /* Closes and shuts down the capture device and session. */ 19 | int ca_av_start(void* cap); /* Start the capture process. */ 20 | int ca_av_stop(void* cap); /* Stop the capture process. */ 21 | void ca_av_set_callback(void* cap, ca::frame_callback fc, void* user); /* Set the callback function which will receive the frames. */ 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/mac/AVFoundation_Interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | C-Interface for the AVFoundation webcam grabber. 4 | 5 | */ 6 | #ifndef VIDEO_CAPTURE_AV_FOUNDATION_INTERFACE_H 7 | #define VIDEO_CAPTURE_AV_FOUNDATION_INTERFACE_H 8 | 9 | #include 10 | #include 11 | 12 | void* ca_av_alloc(); /* Allocate the AVFoundation implementation. */ 13 | void ca_av_dealloc(void* cap); /* Deallocate the AVFoundation implementation */ 14 | int ca_av_get_devices(void* cap, std::vector& result); /* Get available devices. */ 15 | int ca_av_get_capabilities(void* cap, int device, std::vector& result); /* Get capabilities. */ 16 | int ca_av_get_output_formats(void* cap, std::vector& result); /* The AVFoundation frameworks allows conversion of the raw input samples it gets from a webcam into a couple of other output formats. This is not supported by all implementations though. This function returns the formats which are supported. */ 17 | int ca_av_open(void* cap, ca::Settings settings); /* Opens the given capture device with the given settings object. */ 18 | int ca_av_close(void* cap); /* Closes and shuts down the capture device and session. */ 19 | int ca_av_start(void* cap); /* Start the capture process. */ 20 | int ca_av_stop(void* cap); /* Stop the capture process. */ 21 | void ca_av_set_callback(void* cap, ca::frame_callback fc, void* user); /* Set the callback function which will receive the frames. */ 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/uv-linux.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_LINUX_H 23 | #define UV_LINUX_H 24 | 25 | #define UV_PLATFORM_LOOP_FIELDS \ 26 | uv__io_t inotify_read_watcher; \ 27 | void* inotify_watchers; \ 28 | int inotify_fd; \ 29 | 30 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 31 | void* watchers[2]; \ 32 | int wd; \ 33 | 34 | #endif /* UV_LINUX_H */ 35 | -------------------------------------------------------------------------------- /include/streamer/Socket.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAMER_SOCKET_H 2 | #define STREAMER_SOCKET_H 3 | 4 | #include 5 | 6 | #define SOCKET_TYPE_NONE 0x00 7 | #define SOCKET_TYPE_UDP 0x01 8 | #define SOCKET_TYPE_TCP 0x02 9 | 10 | namespace rxs { 11 | 12 | class Loop; 13 | class Socket; 14 | class ReadRequest; 15 | class WriteRequest; 16 | typedef void(*socket_on_read)(ReadRequest* req); 17 | typedef void(*socket_on_write)(WriteRequest* req); 18 | 19 | class Socket { 20 | public: 21 | Socket(Loop* loop, size_t buffersize = 8192); /* Create a new socket with with a buffer of size `buffersize` into which we will write all incoming bytes; it will automatically grow if necessary but you need to make sure to reset the in_dx whenever you've read something, so make sure to set the on_read callback! */ 22 | virtual ~Socket(); /* Cleans up all allocs. */ 23 | virtual int getSocketDescriptor() = 0; /* Get the socket descriptor that is used for e.g. kqueue */ 24 | bool growInputBuffer(); /* This will expand the input buffer to twice it's current size; */ 25 | 26 | public: 27 | uint8_t type; 28 | Loop* loop; /* the loop handler, necessary for handling i/o events. */ 29 | uint8_t* in_buffer; /* when there is data aviable on the socket we read into this buffer, wdx will be set to the end index of the write. */ 30 | uint32_t in_dx; /* write index into in_buffer. */ 31 | uint32_t in_capacity; /* the number of bytes that can be written into in_buffer. */ 32 | socket_on_read on_read; /* will be called whenever we've read some data */ 33 | void* user; /* user data */ 34 | }; 35 | 36 | } /* namespace rxs */ 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/Capture.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Cross Platform Interface 4 | ------------------------ 5 | 6 | This class can be used to read back frames, cross plaftorm, 7 | from a capture device. By default we will select the media capture 8 | SDK for the current OS. Though you can specify what capture wrapper 9 | you want to use by passing one of the valid capture drivers to the 10 | constructor, see the list with supported drives in Types.h 11 | 12 | This class is a thin wrapper around the driver.. 13 | 14 | */ 15 | 16 | #ifndef VIDEO_CAPTURE_VIDEOCAPTURE_H 17 | #define VIDEO_CAPTURE_VIDEOCAPTURE_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #if defined(__APPLE__) 25 | # include 26 | #elif defined(__linux) 27 | # include 28 | #elif defined(_WIN32) 29 | # include 30 | #endif 31 | 32 | namespace ca { 33 | 34 | class Capture { 35 | public: 36 | Capture(frame_callback fc, void* user, int driver = CA_DEFAULT_DRIVER); 37 | ~Capture(); 38 | 39 | /* Interface */ 40 | int open(Settings settings); 41 | int close(); 42 | int start(); 43 | int stop(); 44 | void update(); 45 | 46 | /* Capabilities */ 47 | std::vector getCapabilities(int device); 48 | std::vector getDevices(); 49 | std::vector getOutputFormats(); 50 | 51 | /* Info */ 52 | int listDevices(); 53 | int listCapabilities(int device); 54 | int listOutputFormats(); 55 | int findCapability(int device, int width, int height, int fmt); 56 | 57 | public: 58 | Base* cap; /* The capture implementation */ 59 | }; 60 | 61 | } // namespace ca 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/Capture.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Cross Platform Interface 4 | ------------------------ 5 | 6 | This class can be used to read back frames, cross plaftorm, 7 | from a capture device. By default we will select the media capture 8 | SDK for the current OS. Though you can specify what capture wrapper 9 | you want to use by passing one of the valid capture drivers to the 10 | constructor, see the list with supported drives in Types.h 11 | 12 | This class is a thin wrapper around the driver.. 13 | 14 | */ 15 | 16 | #ifndef VIDEO_CAPTURE_VIDEOCAPTURE_H 17 | #define VIDEO_CAPTURE_VIDEOCAPTURE_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #if defined(__APPLE__) 25 | # include 26 | #elif defined(__linux) 27 | # include 28 | #elif defined(_WIN32) 29 | # include 30 | #endif 31 | 32 | namespace ca { 33 | 34 | class Capture { 35 | public: 36 | Capture(frame_callback fc, void* user, int driver = CA_DEFAULT_DRIVER); 37 | ~Capture(); 38 | 39 | /* Interface */ 40 | int open(Settings settings); 41 | int close(); 42 | int start(); 43 | int stop(); 44 | void update(); 45 | 46 | /* Capabilities */ 47 | std::vector getCapabilities(int device); 48 | std::vector getDevices(); 49 | std::vector getOutputFormats(); 50 | 51 | /* Info */ 52 | int listDevices(); 53 | int listCapabilities(int device); 54 | int listOutputFormats(); 55 | int findCapability(int device, int width, int height, int fmt); 56 | 57 | public: 58 | Base* cap; /* The capture implementation */ 59 | }; 60 | 61 | } // namespace ca 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/streamer/Buffer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace rxs { 6 | 7 | /* --------------------------------------------------------------- */ 8 | 9 | Chunk::Chunk() 10 | :is_free(true) 11 | { 12 | } 13 | 14 | Chunk::~Chunk() { 15 | data.clear(); 16 | is_free = false; 17 | } 18 | 19 | void Chunk::copy(uint8_t* bytes, uint32_t nbytes) { 20 | std::copy(bytes, bytes + nbytes, std::back_inserter(data)); 21 | } 22 | 23 | /* --------------------------------------------------------------- */ 24 | 25 | Buffer::Buffer(uint32_t nsize, int nchunks) { 26 | 27 | printf("Createing %d chunks for our buffer with a size of %u per chunk.\n", nchunks, nsize); 28 | 29 | for (int i = 0; i < nchunks; ++i) { 30 | 31 | Chunk* ar = new Chunk(); 32 | if ( NULL == ar) { 33 | printf("Error: cannot allocate the chunks for the buffer.\n"); 34 | ::exit(1); 35 | } 36 | 37 | ar->data.reserve(nsize); 38 | ar->is_free = true; 39 | free_chunks.push_back(ar); 40 | } 41 | } 42 | 43 | Buffer::~Buffer() { 44 | 45 | /* free our "free" chunks */ 46 | for (size_t i = 0; i < free_chunks.size(); ++i) { 47 | delete free_chunks[i]; 48 | } 49 | free_chunks.clear(); 50 | 51 | /* free our "used" chunks. */ 52 | for (size_t i = 0; i < used_chunks.size(); ++i) { 53 | delete used_chunks[i]; 54 | } 55 | used_chunks.clear(); 56 | } 57 | 58 | Chunk* Buffer::getFreeChunk() { 59 | Chunk* r = NULL; 60 | for (std::vector::iterator it = free_chunks.begin(); it != free_chunks.end(); ++it) { 61 | r = *it; 62 | free_chunks.erase(it); 63 | break; 64 | } 65 | return r; 66 | } 67 | 68 | void Buffer::addUsedChunk(Chunk* c) { 69 | used_chunks.push_back(c); 70 | } 71 | 72 | void Buffer::addFreeChunk(Chunk* c) { 73 | free_chunks.push_back(c); 74 | } 75 | 76 | } /* namespace rxs */ 77 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/uv-linux.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_LINUX_H 23 | #define UV_LINUX_H 24 | 25 | #define UV_PLATFORM_LOOP_FIELDS \ 26 | uv__io_t inotify_read_watcher; \ 27 | void* inotify_watchers; \ 28 | int inotify_fd; \ 29 | 30 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 31 | void* watchers[2]; \ 32 | int wd; \ 33 | 34 | #define UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS 35 | 36 | #endif /* UV_LINUX_H */ 37 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_reconstruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | rxs_reconstruct 4 | --------------- 5 | 6 | rxs_reconstruct takes care of merging rxs_packets with 7 | RTP VP8 data and detecting missing sequence numbers. 8 | 9 | */ 10 | #ifndef RXS_RECONSTRUCT_H 11 | #define RXS_RECONSTRUCT_H 12 | 13 | #include 14 | 15 | typedef struct rxs_reconstruct rxs_reconstruct; 16 | typedef void(*rxs_reconstruct_seqnum_callback)(rxs_reconstruct* rec, uint16_t* seqnums, int num); /* gets called when a packet is added that an invalid sequence number. */ 17 | typedef void(*rxs_reconstruct_frame_callback)(rxs_reconstruct* rec, uint8_t* data, uint32_t nbytes); /* gets called when we've merged a frame */ 18 | 19 | struct rxs_reconstruct { 20 | 21 | /* buffer + checking */ 22 | rxs_packets packets; 23 | uint16_t prev_seqnum; 24 | uint16_t checked_seqnum; 25 | uint8_t* buffer; 26 | uint32_t capacity; 27 | uint8_t found_keyframe; 28 | 29 | /* callbacks */ 30 | void* user; 31 | rxs_reconstruct_seqnum_callback on_missing_seqnum; 32 | rxs_reconstruct_frame_callback on_frame; 33 | }; 34 | 35 | int rxs_reconstruct_init(rxs_reconstruct* recon); /* initialize and allocate necessary memory */ 36 | int rxs_reconstruct_clear(rxs_reconstruct* recon); /* frees all allocated memory and goes back to initial state. */ 37 | int rxs_reconstruct_add_packet(rxs_reconstruct* recon, rxs_packet* pkt); /* add packet */ 38 | int rxs_reconstruct_check_seqnum(rxs_reconstruct* recon, uint16_t seqnum); /* checks if the given seqnum is valid; e.g. monotonically incrementing */ 39 | int rxs_reconstruct_merge_packets(rxs_reconstruct* recon, uint64_t timestamp); /* will try to merge packets for the given timestamp */ 40 | int rxs_reconstruct_is_frame_complete(rxs_packet** packets, int npackets); /* checks if the given array contains all packets that are necessary to create a frame. */ 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/streamer/SocketUDP.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace rxs { 10 | SocketUDP::SocketUDP(Loop* loop, size_t buffersize) 11 | :sock(-1) 12 | ,Socket(loop, buffersize) 13 | ,port(0) 14 | { 15 | type = SOCKET_TYPE_UDP; 16 | } 17 | 18 | SocketUDP::~SocketUDP() { 19 | 20 | if (-1 != sock) { 21 | ::close(sock); 22 | } 23 | 24 | sock = -1; 25 | } 26 | 27 | int SocketUDP::bind(std::string host, uint16_t p) { 28 | int r; 29 | 30 | if (-1 != sock) { return -1; } 31 | if (0 == host.size()) { return -2; } 32 | 33 | ip = host; 34 | port = p; 35 | 36 | /* create sock */ 37 | sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); 38 | if (-1 == sock) { 39 | printf("Error: cannot create udp socket.\n"); 40 | return -3; 41 | } 42 | 43 | /* setup our address hints */ 44 | addr.sin_family = AF_INET; 45 | addr.sin_addr.s_addr = htonl(INADDR_ANY); 46 | addr.sin_port = htons(p); 47 | 48 | /* bind */ 49 | r = ::bind(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr)); 50 | if (0 != r) { 51 | printf("Error: cannot bind the udp socket: %d.\n", r); 52 | return -4; 53 | } 54 | 55 | /* make sure we get events when there is data available */ 56 | if (0 != loop->notifyRead(this)) { 57 | printf("Error: cannot listen to read events.\n"); 58 | return -5; 59 | } 60 | 61 | return 0; 62 | } 63 | 64 | int SocketUDP::sendTo(std::string tip, uint16_t tport, const uint8_t* data, uint32_t nbytes, socket_on_write onwrite, void* udata) { 65 | if (-1 == sock) { return -1; } 66 | struct sockaddr_in addr; 67 | addr.sin_family = AF_INET; 68 | addr.sin_addr.s_addr = inet_addr(tip.c_str()); 69 | addr.sin_port = htons(tport); 70 | return loop->sendTo(this, addr, data, nbytes, onwrite, udata); 71 | } 72 | 73 | } /* namespace rxs */ 74 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/uv-sunos.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_SUNOS_H 23 | #define UV_SUNOS_H 24 | 25 | #include 26 | #include 27 | 28 | /* For the sake of convenience and reduced #ifdef-ery in src/unix/sunos.c, 29 | * add the fs_event fields even when this version of SunOS doesn't support 30 | * file watching. 31 | */ 32 | #define UV_PLATFORM_LOOP_FIELDS \ 33 | uv__io_t fs_event_watcher; \ 34 | int fs_fd; \ 35 | 36 | #if defined(PORT_SOURCE_FILE) 37 | 38 | # define UV_PLATFORM_FS_EVENT_FIELDS \ 39 | file_obj_t fo; \ 40 | int fd; \ 41 | 42 | #endif /* defined(PORT_SOURCE_FILE) */ 43 | 44 | #endif /* UV_SUNOS_H */ 45 | -------------------------------------------------------------------------------- /src/streamer/Controller.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace rxs { 4 | /* -------------------------------------------------------------------------- */ 5 | 6 | static void on_read(ReadRequest* req); 7 | static void on_write(WriteRequest* req); 8 | 9 | /* -------------------------------------------------------------------------- */ 10 | 11 | Controller::Controller(std::string ip, uint16_t port) 12 | :sock(&loop) 13 | ,ip(ip) 14 | ,port(port) 15 | { 16 | } 17 | 18 | Controller::~Controller() { 19 | remotes.clear(); 20 | } 21 | 22 | int Controller::init() { 23 | if (0 == port) { return -1; } 24 | if (0 == ip.size()) { return -2; } 25 | 26 | /* Bind the (UDP) socket */ 27 | if (0 != sock.bind(ip, port)) { 28 | return -3; 29 | } 30 | 31 | sock.on_read = on_read; 32 | sock.user = this; 33 | 34 | return 0; 35 | } 36 | 37 | void Controller::addRemote(std::string rip, uint16_t rport) { 38 | Remote r; 39 | r.ip = rip; 40 | r.port = rport; 41 | remotes.push_back(r); 42 | } 43 | 44 | void Controller::update() { 45 | loop.update(); 46 | } 47 | 48 | /* -------------------------------------------------------------------------- */ 49 | 50 | static void on_read(ReadRequest* req) { 51 | 52 | /* get controller */ 53 | Controller* con = static_cast(req->socket->user); 54 | if (NULL == con) { 55 | printf("Error: the socket user data is not set correctly in Controller. Not supposed to happen.\n"); 56 | return; 57 | } 58 | 59 | Socket* s = req->socket; 60 | if (NULL == s) { 61 | printf("Error: socket member of the read request is NULL. Not supposed to happen.\n"); 62 | return; 63 | } 64 | 65 | for (size_t i = 0; i < con->remotes.size(); ++i) { 66 | Remote rem = con->remotes[i]; 67 | con->sock.sendTo(rem.ip, rem.port, s->in_buffer, s->in_dx, on_write, NULL); 68 | printf("Sending %u bytes to %s:%hu\n", s->in_dx, rem.ip.c_str(), rem.port); 69 | } 70 | 71 | s->in_dx = 0; 72 | } 73 | 74 | static void on_write(WriteRequest* req) { 75 | req->reset(); 76 | } 77 | 78 | } /* namespace rxs */ 79 | -------------------------------------------------------------------------------- /src/examples/test_rxs_streamer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | test_streamer 4 | ------------- 5 | 6 | This file demonstrates a basic example on how to use the 7 | C++ streamer socket code. It creates a UDP server/client and 8 | starts sending data. 9 | 10 | When the server receives data it is automatically stored into 11 | the in_buffer member of the socket. New data will be appended to 12 | this buffer. Whenever you have processed data from this buffer 13 | you need to reset the in_dx member. 14 | 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | static void on_read(rxs::ReadRequest* s); 24 | static void on_written(rxs::WriteRequest* wr); 25 | 26 | int main() { 27 | 28 | printf("\n\ntest_streamer\n\n"); 29 | 30 | /* Create the server and client sockets. */ 31 | rxs::Loop loop; 32 | rxs::SocketUDP server(&loop, 128); 33 | rxs::SocketUDP client(&loop); 34 | 35 | /* Bind the sockets. */ 36 | server.bind("127.0.0.1", 6667); 37 | client.bind("127.0.0.1", 6668); 38 | 39 | /* Whenever the server gets some data, on_read is called. 40 | The data which is read from the socket is stored in the 41 | in_buffer of the socket. You need to make sure to 42 | reset the in_dx which points to the write index. */ 43 | server.on_read = on_read; 44 | 45 | std::string test_data = "Hello world.\n"; 46 | 47 | while(1) { 48 | loop.update(); 49 | client.sendTo("127.0.0.1", 6667, (const uint8_t*)test_data.data(), test_data.size(), on_written, NULL); 50 | usleep(100000); 51 | } 52 | 53 | return 0; 54 | } 55 | 56 | 57 | static void on_read(rxs::ReadRequest* rr) { 58 | rxs::Socket* s = rr->socket; 59 | printf("Read some bytes, current dx: %u.\n", s->in_dx); 60 | for (int i = 0; i < s->in_dx; ++i) { 61 | printf("%c", s->in_buffer[i]); 62 | } 63 | s->in_dx = 0; 64 | 65 | /* note: we don't need to reset the ReadRequest here, because that would mean we won't get any reads anymore. */ 66 | } 67 | 68 | static void on_written(rxs::WriteRequest* wr) { 69 | printf("Ready with writing the data.\n"); 70 | wr->reset(); 71 | } 72 | -------------------------------------------------------------------------------- /src/examples/test_rxs_control.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define RXS_PORT 4455 7 | 8 | rxs_control_sender sender; 9 | rxs_control_receiver receiver; 10 | 11 | static void on_command(rxs_control_receiver* rec); 12 | 13 | static void sigh(int s); 14 | 15 | int main() { 16 | 17 | int i = 0; 18 | int num = 4; /* ask to resend 4 packets */ 19 | 20 | printf("\n\nrxs_control\n\n"); 21 | 22 | signal(SIGINT, sigh); 23 | 24 | if (rxs_control_sender_init(&sender, "0.0.0.0", RXS_PORT) < 0) { 25 | exit(1); 26 | } 27 | 28 | if (rxs_control_receiver_init(&receiver, RXS_PORT) < 0) { 29 | exit(1); 30 | } 31 | 32 | receiver.on_command = on_command; 33 | 34 | /* test some keyframe requests */ 35 | rxs_control_sender_request_keyframe(&sender); 36 | rxs_control_sender_request_keyframe(&sender); 37 | rxs_control_sender_request_keyframe(&sender); 38 | 39 | /* test some packets request */ 40 | for (i = 0; i < num; ++i) { 41 | sender.seqnums[i] = rand(); 42 | printf("Requesting: %d\n", sender.seqnums[i]); 43 | } 44 | rxs_control_sender_request_packets(&sender, sender.seqnums, num); 45 | 46 | while(1) { 47 | rxs_control_receiver_update(&receiver); 48 | rxs_control_sender_update(&sender); 49 | } 50 | 51 | printf("\n"); 52 | return 0; 53 | } 54 | 55 | static void sigh(int s) { 56 | printf("\n\nGot signal!\n\n"); 57 | exit(0); 58 | } 59 | 60 | static void on_command(rxs_control_receiver* rec) { 61 | 62 | int i = 0; 63 | 64 | printf("Command: %d, nr: %d, count: %d\n", 65 | rec->command, 66 | rec->nr, 67 | rec->count); 68 | 69 | switch (rec->command) { 70 | case RXS_CONTROL_COMMAND_KEY_FRAME: { 71 | printf("- Receiver wants a new keyframe.\n"); 72 | break; 73 | } 74 | case RXS_CONTROL_COMMAND_RESEND: { 75 | printf(" - Receiver wants the sender to resend the following packets: \n"); 76 | for (i = 0; i < rec->count; ++i) { 77 | printf(" -- %d\n", rec->seqnums[i]); 78 | } 79 | break; 80 | } 81 | default: { 82 | printf(" - Unhandled commands.\n"); 83 | break; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Files 3 | ```` 4 | - rxs_control.c - used to request lost packets + ask for keyframes (client <> server) 5 | - rxs_decoder.c - libvpx based decoder 6 | - rxs_depacketizer.c - unwraps RTP VP8 packets 7 | - rxs_encoder.c - libvpx based encoder (accepts raw I420 YUV) 8 | - rxs_generator.c - generates YUV420P frames that can be used while testen w/o webcam 9 | - rxs_ivf.c - muxer for VP8 frames, can be converted to e.g. webm with avconv 10 | - rxs_jitter.c - delayed playback buffer, can be used with rxs_control.c to request packets and you have some time to re-receive lost packets 11 | - rxs_packetizer.c - wraps vp8 data into rtp / rtp-vp8 packets 12 | - rxs_packets.c - packets buffer 13 | - rxs_receiver.c - UDP based receiver; does some network i/o 14 | - rxs_reconstruct.c - reconstructs VP8 frames that are unwrapped using rxs_depacketizer.c (one vp8 frame is sent using multiple RTP packets) 15 | - rxs_sender.c - UDP based sender; does some network i/o 16 | - rxs_stun.c - basic STUN implementation (udp hole punching) 17 | - rxs_stun_io.c - networkign for rxs_stun 18 | 19 | ```` 20 | 21 | 22 | References: 23 | - [Experimental Investigation of the Google Congestion Control for Real Time Flows](http://c3lab.poliba.it/images/0/07/Webrtc_cc-Fhcmn2013.pdf) 24 | - [Performance Analysis of Receive Side Real Time Congestion Control for WebRTC](http://www.netlab.tkk.fi/~jo/papers/2013-12-pv-webrtc-cc.pdf) 25 | - [Handling Packet Loss in WebRTC](http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/41611.pdf) 26 | - [Congestion Control using FEC for Conversational Multimedia Communication](http://www.netlab.tkk.fi/~varun/nagy2014mmsys.pdf) 27 | - [RFC 5109](http://tools.ietf.org/html/rfc5109) 28 | - [James S. Plank, FEC library in C](http://web.eecs.utk.edu/~plank/plank/papers/CS-08-627.html) 29 | - [The World Of Peer 2 Peer, great STUN info](http://en.wikibooks.org/wiki/The_World_of_Peer-to-Peer_(P2P)/Building_a_P2P_System) 30 | - [FEC Frame for WebRTC](http://www.ietf.org/proceedings/86/slides/slides-86-rtcweb-1.pdf) 31 | - [Handling Packet Loss in WebRTC](http://2013.ieeeicip.org/proc/pdfs/0001860.pdf) 32 | - [RFC: Forward Error Correction for WebRTC using FEC FRAME](http://tools.ietf.org/html/draft-mandyam-rtcweb-fecframe-00) 33 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/libyuv/scale_argb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_SCALE_ARGB_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_SCALE_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/scale.h" // For FilterMode 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | LIBYUV_API 23 | int ARGBScale(const uint8* src_argb, int src_stride_argb, 24 | int src_width, int src_height, 25 | uint8* dst_argb, int dst_stride_argb, 26 | int dst_width, int dst_height, 27 | enum FilterMode filtering); 28 | 29 | // Clipped scale takes destination rectangle coordinates for clip values. 30 | LIBYUV_API 31 | int ARGBScaleClip(const uint8* src_argb, int src_stride_argb, 32 | int src_width, int src_height, 33 | uint8* dst_argb, int dst_stride_argb, 34 | int dst_width, int dst_height, 35 | int clip_x, int clip_y, int clip_width, int clip_height, 36 | enum FilterMode filtering); 37 | 38 | // TODO(fbarchard): Implement this. 39 | // Scale with YUV conversion to ARGB and clipping. 40 | LIBYUV_API 41 | int YUVToARGBScaleClip(const uint8* src_y, int src_stride_y, 42 | const uint8* src_u, int src_stride_u, 43 | const uint8* src_v, int src_stride_v, 44 | uint32 src_fourcc, 45 | int src_width, int src_height, 46 | uint8* dst_argb, int dst_stride_argb, 47 | uint32 dst_fourcc, 48 | int dst_width, int dst_height, 49 | int clip_x, int clip_y, int clip_width, int clip_height, 50 | enum FilterMode filtering); 51 | 52 | #ifdef __cplusplus 53 | } // extern "C" 54 | } // namespace libyuv 55 | #endif 56 | 57 | #endif // INCLUDE_LIBYUV_SCALE_ARGB_H_ NOLINT 58 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/libyuv/scale_argb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_SCALE_ARGB_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_SCALE_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/scale.h" // For FilterMode 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | LIBYUV_API 23 | int ARGBScale(const uint8* src_argb, int src_stride_argb, 24 | int src_width, int src_height, 25 | uint8* dst_argb, int dst_stride_argb, 26 | int dst_width, int dst_height, 27 | enum FilterMode filtering); 28 | 29 | // Clipped scale takes destination rectangle coordinates for clip values. 30 | LIBYUV_API 31 | int ARGBScaleClip(const uint8* src_argb, int src_stride_argb, 32 | int src_width, int src_height, 33 | uint8* dst_argb, int dst_stride_argb, 34 | int dst_width, int dst_height, 35 | int clip_x, int clip_y, int clip_width, int clip_height, 36 | enum FilterMode filtering); 37 | 38 | // TODO(fbarchard): Implement this. 39 | // Scale with YUV conversion to ARGB and clipping. 40 | LIBYUV_API 41 | int YUVToARGBScaleClip(const uint8* src_y, int src_stride_y, 42 | const uint8* src_u, int src_stride_u, 43 | const uint8* src_v, int src_stride_v, 44 | uint32 src_fourcc, 45 | int src_width, int src_height, 46 | uint8* dst_argb, int dst_stride_argb, 47 | uint32 dst_fourcc, 48 | int dst_width, int dst_height, 49 | int clip_x, int clip_y, int clip_width, int clip_height, 50 | enum FilterMode filtering); 51 | 52 | #ifdef __cplusplus 53 | } // extern "C" 54 | } // namespace libyuv 55 | #endif 56 | 57 | #endif // INCLUDE_LIBYUV_SCALE_ARGB_H_ NOLINT 58 | -------------------------------------------------------------------------------- /src/examples/test_rxs_signal_redis.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | test_signal_redis 4 | ----------------- 5 | 6 | Using redis as signaling intermediate. We're making use of the redis 7 | pub/sub feature. Note that when you're subscribed to a channel you 8 | cannot change/set values using rxs_signal_store_address() 9 | 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | rxs_signal sig_pub; 17 | rxs_signal sig_sub; 18 | rxs_signal sig_retr; 19 | uint64_t timeout; 20 | uint64_t delay; 21 | uint64_t now; 22 | 23 | static void on_address(rxs_signal* signal, char* ip, uint16_t port); 24 | 25 | int main() { 26 | 27 | printf("\n\ntest_signal_redis\n\n"); 28 | 29 | // subscriber. 30 | if (rxs_signal_init(&sig_sub, "home.roxlu.com", 6379) < 0) { 31 | printf("Error: rxs_signal_init() failed. (2)\n"); 32 | exit(1); 33 | } 34 | 35 | if (rxs_signal_subscribe(&sig_sub, 5) < 0) { 36 | printf("Error: rxs_signal_subscribe() failed.\n"); 37 | exit(1); 38 | } 39 | 40 | sig_sub.on_address = on_address; 41 | 42 | // publisher 43 | if (rxs_signal_init(&sig_pub, "home.roxlu.com", 6379) < 0) { 44 | printf("Error: rxs_signal_init() failed. (1)\n"); 45 | exit(1); 46 | } 47 | 48 | delay = 1 * 1000llu * 1000llu * 1000llu; 49 | timeout = uv_hrtime() + delay; 50 | 51 | // retriever 52 | if (rxs_signal_init(&sig_retr, "home.roxlu.com", 6379) < 0) { 53 | printf("Error: rxs_signal_init() failed. (3)\n"); 54 | exit(1); 55 | } 56 | if (rxs_signal_retrieve_address(&sig_retr, 5) < 0) { 57 | printf("Error: rxs_signal_retrieve_address() failed.\n"); 58 | exit(1); 59 | } 60 | 61 | sig_retr.on_address = on_address; 62 | 63 | while(1) { 64 | 65 | /* every n-seconds publish the ip on slot 5. */ 66 | now = uv_hrtime(); 67 | if (now > timeout) { 68 | timeout = now + delay; 69 | if (rxs_signal_store_address(&sig_pub, 5, "127.0.0.2", 1234) < 0) { 70 | printf("rxs_signal_store_address() failed.\n"); 71 | exit(1); 72 | } 73 | } 74 | 75 | rxs_signal_update(&sig_pub); 76 | rxs_signal_update(&sig_sub); 77 | rxs_signal_update(&sig_retr); 78 | } 79 | 80 | return 0; 81 | } 82 | 83 | static void on_address(rxs_signal* signal, char* ip, uint16_t port) { 84 | printf("-- received address: %s:%d\n", ip, port); 85 | } 86 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_encoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | rxs_encoder 4 | ----------- 5 | The rxs_encoder encoder raw I420 frames using VP8 and calls the set on_packet 6 | callback when it has some encoded data. At the moment of writing each packet 7 | that is passed into the on_packet callback will contain one VP8 partition which 8 | makes it easy to encapsulate in a RTP VP8 packet. 9 | 10 | */ 11 | #ifndef RXS_ENCODER_H 12 | #define RXS_ENCODER_H 13 | 14 | #define VPX_CODEC_DISABLE_COMPAT 1 15 | #include 16 | #include 17 | #include 18 | #define vpx_cx_interface (vpx_codec_vp8_cx()) 19 | 20 | typedef struct rxs_encoder rxs_encoder; 21 | typedef struct rxs_encoder_config rxs_encoder_config; 22 | typedef void (*rxs_pkt_callback)(rxs_encoder* enc, const vpx_codec_cx_pkt_t* pkt, int64_t pts); /* the `on_packet` callback which is called when the encoder outputs an packet. */ 23 | 24 | struct rxs_encoder_config { 25 | uint32_t width; /* height of the image buffer you pass into rxs_encoder_encode, as I420 (or any other supported format) */ 26 | uint32_t height; /* height of the image buffer you pass into rxs_encoder_encode, as I420 (or any other supported format) */ 27 | int fps_num; /* FPS numerator, e.g. 1 */ 28 | int fps_den; /* FPS denumerator, e.g. 25 for 25fps */ 29 | int fmt; /* the pixel format of the pixels you pass into rxs_encoder_encode, e.g VPX_IMG_FMT_I420. */ 30 | }; 31 | 32 | struct rxs_encoder { 33 | vpx_image_t img; 34 | vpx_codec_enc_cfg_t cfg; 35 | vpx_codec_ctx_t ctx; 36 | int width; 37 | int height; 38 | int fps_num; 39 | int fps_den; 40 | int fmt; /* pixel format that is used to pass data into rxs_encoder_encode().. */ 41 | unsigned long frame_duration; 42 | int flags; /* encoder flags, e.g. used by rxs_encoder_request_keyframe */ 43 | 44 | /* callbacks */ 45 | void* user; 46 | rxs_pkt_callback on_packet; 47 | }; 48 | 49 | int rxs_encoder_init(rxs_encoder* enc, rxs_encoder_config* cfg); /* initialize the encoder */ 50 | int rxs_encoder_encode(rxs_encoder* enc, unsigned char* pixels, int64_t pts); /* encode the given buffer */ 51 | int rxs_encoder_request_keyframe(rxs_encoder* enc); /* will ask the encoder to return a keyframe */ 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /include/streamer/Buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAMER_BUFFER_H 2 | #define STREAMER_BUFFER_H 3 | 4 | #include 5 | #include 6 | 7 | namespace rxs { 8 | 9 | /* --------------------------------------------------------------- */ 10 | 11 | class Chunk { 12 | public: 13 | Chunk(); 14 | ~Chunk(); 15 | void copy(uint8_t* bytes, uint32_t nbytes); /* Copy the given bytes into the internal buffer */ 16 | size_t capacity(); /* Returns how many bytes you can write into this chunk. */ 17 | size_t size(); /* Returns the number of bytes written into this chunk */ 18 | void clear(); /* Resets the buffer; should be called when you want to reset the data */ 19 | uint8_t* ptr(); /* Returns pointer to first entry */ 20 | public: 21 | std::vector data; /* The buffer into you write your data. */ 22 | bool is_free; /* Indicates is this chunk is in use or if you can write into the member. */ 23 | void* user; /* User data */ 24 | }; 25 | 26 | /* --------------------------------------------------------------- */ 27 | 28 | inline size_t Chunk::capacity() { 29 | return data.capacity(); 30 | } 31 | 32 | inline size_t Chunk::size() { 33 | return data.size(); 34 | } 35 | 36 | inline uint8_t* Chunk::ptr() { 37 | return &data[0]; 38 | } 39 | 40 | inline void Chunk::clear() { 41 | data.clear(); 42 | } 43 | 44 | /* --------------------------------------------------------------- */ 45 | 46 | class Buffer { 47 | public: 48 | Buffer(uint32_t nsize, int nchunks); /* Create nchunks of nsize */ 49 | ~Buffer(); /* Destructor, will free all allocate memory / chunks */ 50 | Chunk* getFreeChunk(); /* Returns the next free chunk from the list of internal chunks an also setting the chunk to non free */ 51 | void addUsedChunk(Chunk* c); 52 | void addFreeChunk(Chunk* c); 53 | 54 | public: 55 | std::vector free_chunks; /* The collection of chunks. */ 56 | std::vector used_chunks; /* The collection of chunks. */ 57 | }; 58 | 59 | } /* namespace rxs */ 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_ivf.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | rxs_ivf 4 | ------- 5 | Based on http://www.webmproject.org/docs/vp8-sdk/example__simple__encoder.html the 6 | rxs_ivf code is used to store VPX frames into a very simple file format that can 7 | be used with avconv to mux it into a playable format. Created this for testing the 8 | RTP-VP8 stream. 9 | 10 | You can use avconv to mux the ivf into a webm file: 11 | 12 | ````sh 13 | ./avconv -f ivf -i test.ivf -vcodec copy out.webm 14 | ```` 15 | 16 | Example: 17 | 18 | ````C 19 | 20 | // create the ivf writer 21 | if (rxs_ivf_init(&ivf) < 0) { 22 | printf("Error: cannot create the ivf.\n"); 23 | exit(1); 24 | } 25 | 26 | ivf.width = WIDTH; 27 | ivf.height = HEIGHT; 28 | ivf.timebase_num = 1; 29 | ivf.timebase_den = FPS; 30 | 31 | if (rxs_ivf_create(&ivf, "output.ivf") < 0) { 32 | printf("Error: cannot create the ivf file.\n"); 33 | exit(1); 34 | } 35 | 36 | // write frames! 37 | rxs_ivf_write_frame(&ivf, pts, pkt->data.frame.buf, pkt->data.frame.sz); 38 | 39 | // cleanup, close file 40 | rxs_ivf_destroy(&ivf); 41 | 42 | ```` 43 | 44 | */ 45 | #ifndef ROXLU_RXS_IVF_H 46 | #define ROXLU_RXS_IVF_H 47 | 48 | #include 49 | #include 50 | #include 51 | 52 | typedef struct rxs_ivf rxs_ivf; 53 | 54 | struct rxs_ivf { 55 | /* generic */ 56 | FILE* fp; 57 | 58 | /* ivf header info */ 59 | uint16_t version; 60 | uint16_t width; 61 | uint16_t height; 62 | uint32_t timebase_den; 63 | uint32_t timebase_num; 64 | uint64_t num_frames; 65 | }; 66 | 67 | int rxs_ivf_init(rxs_ivf* k); /* initializes all members to initial values */ 68 | int rxs_ivf_create(rxs_ivf* k, const char* filename); 69 | int rxs_ivf_write_header(rxs_ivf* k); 70 | int rxs_ivf_write_frame(rxs_ivf* k, uint64_t timestamp, uint8_t* data, uint32_t len); 71 | int rxs_ivf_write_u8(rxs_ivf* k, uint8_t data); 72 | int rxs_ivf_write_u16(rxs_ivf* k, uint16_t data); 73 | int rxs_ivf_write_u32(rxs_ivf* k, uint32_t data); 74 | int rxs_ivf_write_u64(rxs_ivf* k, uint64_t data); 75 | int rxs_ivf_write(rxs_ivf* k, uint8_t* data, uint32_t len); 76 | int rxs_ivf_destroy(rxs_ivf* k); 77 | 78 | int rxs_ivf_open(rxs_ivf* k); 79 | int rxs_ivf_read_header(rxs_ivf* k); 80 | int rxs_ivf_read_frame(rxs_ivf* k); 81 | uint8_t rxs_ivf_read_u8(rxs_ivf* k); 82 | uint16_t rxs_ivf_read_u16(rxs_ivf* k); 83 | uint32_t rxs_ivf_read_u32(rxs_ivf* k); 84 | uint64_t rxs_ivf_read_u64(rxs_ivf* k); 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_stun_io.h: -------------------------------------------------------------------------------- 1 | #ifndef RXS_STUN_IO_H 2 | #define RXS_STUN_IO_H 3 | 4 | #include 5 | #include 6 | 7 | #define RXS_STUN_IO_NUM_MEM_BLOCKS 16 8 | #define RXS_STUN_IO_MEM_BLOCK_SIZE (64 * 1024) 9 | 10 | #define RXS_SIO_STATE_NONE 0 /* default state, will kickoff resolving when rxs_stun_io_init() is called. */ 11 | #define RXS_SIO_STATE_RESOLVED 1 /* IP of stun server is resolved. */ 12 | 13 | typedef struct rxs_stun_io rxs_stun_io; 14 | typedef struct rxs_stun_mem rxs_stun_mem; 15 | 16 | //typedef void(*rxs_stun_io_address_cb)(rxs_stun_io* io, struct sockaddr_in* addr); /* gets called when we got a reply from the stun server and we know our public IP:PORT */ 17 | typedef void(*rxs_stun_io_address_cb)(rxs_stun_io* io, const char* ip, uint16_t port); /* gets called when we got a reply from the stun server and we know our public IP:PORT */ 18 | 19 | struct rxs_stun_mem { 20 | char data[RXS_STUN_IO_MEM_BLOCK_SIZE]; /* used to store the data */ 21 | int is_free; /* is set to 1 when this memory block isn't used */ 22 | uint32_t nbytes; /* number of bytes stored, is set in on_alloc*/ 23 | rxs_stun_io* io; /* pointer to our rxs_stun_io */ 24 | }; 25 | 26 | struct rxs_stun_io { 27 | struct sockaddr_in saddr; /* address to which we send udp data */ 28 | uv_udp_t sock; 29 | uv_getaddrinfo_t resolver; 30 | uv_loop_t* loop; 31 | rxs_stun stun; 32 | uint16_t port; 33 | char ip[17]; /* ip of stun server */ 34 | rxs_stun_mem mem[RXS_STUN_IO_NUM_MEM_BLOCKS]; /* very basic memory mangement for now. */ 35 | int state; /* used to keep state; */ 36 | uint64_t keepalive_timeout; /* every keepalive_delay nanos we send a binding indication. */ 37 | uint64_t keepalive_delay; /* delay in ns. between each keep alive message */ 38 | 39 | /* callback */ 40 | void* user; 41 | rxs_stun_io_address_cb on_address; /* simply dispatches the on_attr call from rxs_stun. */ 42 | 43 | /* begin - test listening */ 44 | int listening; 45 | uv_udp_t listen_sock; 46 | /* end - test listening */ 47 | }; 48 | 49 | int rxs_stun_io_init(rxs_stun_io* io, const char* server, const char* port); 50 | void rxs_stun_io_update(rxs_stun_io* io); 51 | int rxs_stun_io_clear(rxs_stun_io* io); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_packetizer.h: -------------------------------------------------------------------------------- 1 | #ifndef RXS_PACKETIZER_H 2 | #define RXS_PACKETIZER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define RXS_PACK_BUFFER_SIZE (1024 * 1024) 10 | 11 | typedef struct rxs_packetizer rxs_packetizer; 12 | typedef void (*rxs_packetizer_callback)(rxs_packetizer* rxs, uint8_t* buffer, uint32_t nbytes); /* is called when we have a rtp packet ready. */ 13 | 14 | struct rxs_packetizer { 15 | 16 | /* RTP header */ 17 | uint8_t version; /* the version, 2 */ 18 | uint8_t padding; /* padding bit in rtp header */ 19 | uint8_t extension; /* extension bit in rtp header */ 20 | uint8_t cc; /* number of CSRC identifiers */ 21 | uint8_t marker; /* the rtp m bit, must be set for the last packet of a frame */ 22 | uint8_t payload_type; /* payload type */ 23 | uint32_t ssrc; /* our identifier */ 24 | uint16_t seqnum; /* current packet sequence number, increments for eaach packet */ 25 | uint32_t timestamp; /* timestamp at the rate that vp8 wants */ 26 | 27 | /* VP8 RTP */ 28 | uint8_t extended; /* should we add extension header */ 29 | uint8_t pstart; /* start of vp8 partition */ 30 | uint8_t nonref; 31 | uint8_t pid; /* partition id */ 32 | int16_t picture_id; /* PictureID field */ 33 | 34 | uint32_t dx; /* write index into rxs_packetiser.dx */ 35 | uint32_t frame_dx; /* index into the vpx_codec_cx_pkt_t.data.frame.buf */ 36 | int64_t frame_len; /* number of read bytes from the frame/vpx packet */ 37 | int64_t frame_size; /* payload size for the current packet */ 38 | 39 | uint8_t buffer[RXS_PACK_BUFFER_SIZE]; /* large buffer into which we store the current rtp packet */ 40 | 41 | /* callback */ 42 | void* user; 43 | rxs_packetizer_callback on_packet; 44 | }; 45 | 46 | int rxs_packetizer_init(rxs_packetizer* vpx); 47 | int rxs_packetizer_wrap(rxs_packetizer* vpx, const vpx_codec_cx_pkt_t* pkt); 48 | int rxs_packetizer_reset(rxs_packetizer* vpx); /* resets all members to defaults, but not the one which needs to be set (like ssrc)*/ 49 | void rxs_packetizer_print(rxs_packetizer* vpx); /* print some debug info */ 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/libyuv/compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_COMPARE_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_COMPARE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Compute a hash for specified memory. Seed of 5381 recommended. 22 | LIBYUV_API 23 | uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed); 24 | 25 | // Sum Square Error - used to compute Mean Square Error or PSNR. 26 | LIBYUV_API 27 | uint64 ComputeSumSquareError(const uint8* src_a, 28 | const uint8* src_b, int count); 29 | 30 | LIBYUV_API 31 | uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a, 32 | const uint8* src_b, int stride_b, 33 | int width, int height); 34 | 35 | static const int kMaxPsnr = 128; 36 | 37 | LIBYUV_API 38 | double SumSquareErrorToPsnr(uint64 sse, uint64 count); 39 | 40 | LIBYUV_API 41 | double CalcFramePsnr(const uint8* src_a, int stride_a, 42 | const uint8* src_b, int stride_b, 43 | int width, int height); 44 | 45 | LIBYUV_API 46 | double I420Psnr(const uint8* src_y_a, int stride_y_a, 47 | const uint8* src_u_a, int stride_u_a, 48 | const uint8* src_v_a, int stride_v_a, 49 | const uint8* src_y_b, int stride_y_b, 50 | const uint8* src_u_b, int stride_u_b, 51 | const uint8* src_v_b, int stride_v_b, 52 | int width, int height); 53 | 54 | LIBYUV_API 55 | double CalcFrameSsim(const uint8* src_a, int stride_a, 56 | const uint8* src_b, int stride_b, 57 | int width, int height); 58 | 59 | LIBYUV_API 60 | double I420Ssim(const uint8* src_y_a, int stride_y_a, 61 | const uint8* src_u_a, int stride_u_a, 62 | const uint8* src_v_a, int stride_v_a, 63 | const uint8* src_y_b, int stride_y_b, 64 | const uint8* src_u_b, int stride_u_b, 65 | const uint8* src_v_b, int stride_v_b, 66 | int width, int height); 67 | 68 | #ifdef __cplusplus 69 | } // extern "C" 70 | } // namespace libyuv 71 | #endif 72 | 73 | #endif // INCLUDE_LIBYUV_COMPARE_H_ NOLINT 74 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/libyuv/compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_COMPARE_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_COMPARE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Compute a hash for specified memory. Seed of 5381 recommended. 22 | LIBYUV_API 23 | uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed); 24 | 25 | // Sum Square Error - used to compute Mean Square Error or PSNR. 26 | LIBYUV_API 27 | uint64 ComputeSumSquareError(const uint8* src_a, 28 | const uint8* src_b, int count); 29 | 30 | LIBYUV_API 31 | uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a, 32 | const uint8* src_b, int stride_b, 33 | int width, int height); 34 | 35 | static const int kMaxPsnr = 128; 36 | 37 | LIBYUV_API 38 | double SumSquareErrorToPsnr(uint64 sse, uint64 count); 39 | 40 | LIBYUV_API 41 | double CalcFramePsnr(const uint8* src_a, int stride_a, 42 | const uint8* src_b, int stride_b, 43 | int width, int height); 44 | 45 | LIBYUV_API 46 | double I420Psnr(const uint8* src_y_a, int stride_y_a, 47 | const uint8* src_u_a, int stride_u_a, 48 | const uint8* src_v_a, int stride_v_a, 49 | const uint8* src_y_b, int stride_y_b, 50 | const uint8* src_u_b, int stride_u_b, 51 | const uint8* src_v_b, int stride_v_b, 52 | int width, int height); 53 | 54 | LIBYUV_API 55 | double CalcFrameSsim(const uint8* src_a, int stride_a, 56 | const uint8* src_b, int stride_b, 57 | int width, int height); 58 | 59 | LIBYUV_API 60 | double I420Ssim(const uint8* src_y_a, int stride_y_a, 61 | const uint8* src_u_a, int stride_u_a, 62 | const uint8* src_v_a, int stride_v_a, 63 | const uint8* src_y_b, int stride_y_b, 64 | const uint8* src_u_b, int stride_u_b, 65 | const uint8* src_v_b, int stride_v_b, 66 | int width, int height); 67 | 68 | #ifdef __cplusplus 69 | } // extern "C" 70 | } // namespace libyuv 71 | #endif 72 | 73 | #endif // INCLUDE_LIBYUV_COMPARE_H_ NOLINT 74 | -------------------------------------------------------------------------------- /src/rxs_streamer/rxs_sender.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /* ----------------------------------------------------------------------------- */ 7 | 8 | static void send_cb(uv_udp_send_t* req, int status); 9 | 10 | /* ----------------------------------------------------------------------------- */ 11 | 12 | int rxs_sender_init(rxs_sender* net, const char* ip, int port) { 13 | int r; 14 | 15 | if (!net) { return -1; } 16 | 17 | /* get default loop */ 18 | net->loop = uv_default_loop(); 19 | if (!net->loop) { 20 | printf("Error: cannot get default loop in sender.\n"); 21 | return -2; 22 | } 23 | 24 | /* init sock */ 25 | r = uv_udp_init(net->loop, &net->send_sock); 26 | if (r != 0) { 27 | printf("Error: cannot initialize uv_udp_t in sender.\n"); 28 | return -3; 29 | } 30 | 31 | /* create ip4 addr */ 32 | r = uv_ip4_addr(ip, port, &net->saddr); 33 | if (r != 0) { 34 | printf("Error: cannot create addr struct for sender: %s\n", uv_strerror(r)); 35 | return -4; 36 | } 37 | 38 | return 0; 39 | } 40 | 41 | int rxs_sender_send(rxs_sender* net, uint8_t* buffer, uint32_t nbytes) { 42 | 43 | char* tmp = NULL; 44 | int r; 45 | uv_buf_t b; 46 | uv_udp_send_t* req = NULL; 47 | 48 | if (!net) { return -1; } 49 | if (!buffer) { return -2; } 50 | if (!nbytes) { return -3; } 51 | 52 | /* we should copy the buf here... */ 53 | tmp = (char*)malloc(nbytes); 54 | if (NULL == tmp) { 55 | printf("Error: cannot allocate BUF.\n"); 56 | return -4; 57 | } 58 | memcpy(tmp, buffer, nbytes); 59 | 60 | /* @todo - the tests of libuv use this, but I'm pretty sure we want to allocate on the heap here */ 61 | 62 | b = uv_buf_init((char*)tmp, nbytes); 63 | req = (uv_udp_send_t*)malloc(sizeof(uv_udp_send_t)); 64 | if (NULL == req) { 65 | printf("Error: cannot allocate REQ.\n"); 66 | return -4; 67 | } 68 | memset(req, 0x00, sizeof(uv_udp_send_t)); 69 | 70 | req->data = tmp; 71 | r = uv_udp_send(req, &net->send_sock, &b, 1, (const struct sockaddr*)&net->saddr, send_cb); 72 | 73 | if (r != 0) { 74 | printf("Error: cannot send udp: %s\n", uv_strerror(r)); 75 | /* @todo -> shouldn't we free the allocated buffer here? */ 76 | return -1; 77 | } 78 | return 0; 79 | } 80 | 81 | void rxs_sender_update(rxs_sender* net){ 82 | uv_run(net->loop, UV_RUN_NOWAIT); 83 | //uv_run(net->loop, UV_RUN_ONCE); 84 | //uv_run(net->loop, UV_RUN_DEFAULT); 85 | } 86 | 87 | /* ----------------------------------------------------------------------------- */ 88 | 89 | static void send_cb(uv_udp_send_t* req, int status) { 90 | 91 | char* data = (char*)req->data; 92 | 93 | free(data); 94 | data = NULL; 95 | 96 | free(req); 97 | req = NULL; 98 | } 99 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/libyuv/cpu_id.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_CPU_ID_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_CPU_ID_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // TODO(fbarchard): Consider overlapping bits for different architectures. 22 | // Internal flag to indicate cpuid requires initialization. 23 | #define kCpuInit 0x1 24 | 25 | // These flags are only valid on ARM processors. 26 | static const int kCpuHasARM = 0x2; 27 | static const int kCpuHasNEON = 0x4; 28 | // 0x8 reserved for future ARM flag. 29 | 30 | // These flags are only valid on x86 processors. 31 | static const int kCpuHasX86 = 0x10; 32 | static const int kCpuHasSSE2 = 0x20; 33 | static const int kCpuHasSSSE3 = 0x40; 34 | static const int kCpuHasSSE41 = 0x80; 35 | static const int kCpuHasSSE42 = 0x100; 36 | static const int kCpuHasAVX = 0x200; 37 | static const int kCpuHasAVX2 = 0x400; 38 | static const int kCpuHasERMS = 0x800; 39 | static const int kCpuHasFMA3 = 0x1000; 40 | // 0x2000, 0x4000, 0x8000 reserved for future X86 flags. 41 | 42 | // These flags are only valid on MIPS processors. 43 | static const int kCpuHasMIPS = 0x10000; 44 | static const int kCpuHasMIPS_DSP = 0x20000; 45 | static const int kCpuHasMIPS_DSPR2 = 0x40000; 46 | 47 | // Internal function used to auto-init. 48 | LIBYUV_API 49 | int InitCpuFlags(void); 50 | 51 | // Internal function for parsing /proc/cpuinfo. 52 | LIBYUV_API 53 | int ArmCpuCaps(const char* cpuinfo_name); 54 | 55 | // Detect CPU has SSE2 etc. 56 | // Test_flag parameter should be one of kCpuHas constants above. 57 | // returns non-zero if instruction set is detected 58 | static __inline int TestCpuFlag(int test_flag) { 59 | LIBYUV_API extern int cpu_info_; 60 | return (cpu_info_ == kCpuInit ? InitCpuFlags() : cpu_info_) & test_flag; 61 | } 62 | 63 | // For testing, allow CPU flags to be disabled. 64 | // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. 65 | // MaskCpuFlags(-1) to enable all cpu specific optimizations. 66 | // MaskCpuFlags(0) to disable all cpu specific optimizations. 67 | LIBYUV_API 68 | void MaskCpuFlags(int enable_flags); 69 | 70 | // Low level cpuid for X86. Returns zeros on other CPUs. 71 | // eax is the info type that you want. 72 | // ecx is typically the cpu number, and should normally be zero. 73 | LIBYUV_API 74 | void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info); 75 | 76 | #ifdef __cplusplus 77 | } // extern "C" 78 | } // namespace libyuv 79 | #endif 80 | 81 | #endif // INCLUDE_LIBYUV_CPU_ID_H_ NOLINT 82 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/libyuv/cpu_id.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_CPU_ID_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_CPU_ID_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // TODO(fbarchard): Consider overlapping bits for different architectures. 22 | // Internal flag to indicate cpuid requires initialization. 23 | static const int kCpuInit = 0x1; 24 | 25 | // These flags are only valid on ARM processors. 26 | static const int kCpuHasARM = 0x2; 27 | static const int kCpuHasNEON = 0x4; 28 | // 0x8 reserved for future ARM flag. 29 | 30 | // These flags are only valid on x86 processors. 31 | static const int kCpuHasX86 = 0x10; 32 | static const int kCpuHasSSE2 = 0x20; 33 | static const int kCpuHasSSSE3 = 0x40; 34 | static const int kCpuHasSSE41 = 0x80; 35 | static const int kCpuHasSSE42 = 0x100; 36 | static const int kCpuHasAVX = 0x200; 37 | static const int kCpuHasAVX2 = 0x400; 38 | static const int kCpuHasERMS = 0x800; 39 | static const int kCpuHasFMA3 = 0x1000; 40 | // 0x2000, 0x4000, 0x8000 reserved for future X86 flags. 41 | 42 | // These flags are only valid on MIPS processors. 43 | static const int kCpuHasMIPS = 0x10000; 44 | static const int kCpuHasMIPS_DSP = 0x20000; 45 | static const int kCpuHasMIPS_DSPR2 = 0x40000; 46 | 47 | // Internal function used to auto-init. 48 | LIBYUV_API 49 | int InitCpuFlags(void); 50 | 51 | // Internal function for parsing /proc/cpuinfo. 52 | LIBYUV_API 53 | int ArmCpuCaps(const char* cpuinfo_name); 54 | 55 | // Detect CPU has SSE2 etc. 56 | // Test_flag parameter should be one of kCpuHas constants above. 57 | // returns non-zero if instruction set is detected 58 | static __inline int TestCpuFlag(int test_flag) { 59 | LIBYUV_API extern int cpu_info_; 60 | return (cpu_info_ == kCpuInit ? InitCpuFlags() : cpu_info_) & test_flag; 61 | } 62 | 63 | // For testing, allow CPU flags to be disabled. 64 | // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. 65 | // MaskCpuFlags(-1) to enable all cpu specific optimizations. 66 | // MaskCpuFlags(0) to disable all cpu specific optimizations. 67 | LIBYUV_API 68 | void MaskCpuFlags(int enable_flags); 69 | 70 | // Low level cpuid for X86. Returns zeros on other CPUs. 71 | // eax is the info type that you want. 72 | // ecx is typically the cpu number, and should normally be zero. 73 | LIBYUV_API 74 | void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info); 75 | 76 | #ifdef __cplusplus 77 | } // extern "C" 78 | } // namespace libyuv 79 | #endif 80 | 81 | #endif // INCLUDE_LIBYUV_CPU_ID_H_ NOLINT 82 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_generator.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | rxs_generator 4 | ------------- 5 | 6 | Creates a test video signal with 7 colors vertical bars 7 | and one moving horizontal. First initialize the generator using 8 | `rxs_generator_init()` then call `rxs_generator_update()`. Each time you 9 | call `rxs_generator_update()` it will update the frame and y, u, v planes. 10 | When ready clean memory using `rxs_generator_clear()`. 11 | 12 | You can write the frames into a file and use avconv to encode it to some format: 13 | 14 | ````sh 15 | ./avconv -f rawvideo -pix_fmt yuv420p -s 640x480 -i output.yuv -vcodec h264 -r 25 -y out.mov 16 | ```` 17 | 18 | TODO 19 | ----- 20 | - There are many things we could optimise. 21 | 22 | Example: 23 | -------- 24 | 25 | 26 | fp = fopen("output.yuv", "wb"); 27 | 28 | rxs_generator gen; 29 | 30 | if (rxs_generator_init(&gen, WIDTH, HEIGHT, FPS) < 0) { 31 | printf("Error: cannot initialize the generator.\n"); 32 | exit(1); 33 | } 34 | 35 | while(1) { 36 | 37 | printf("Frame: %llu\n", gen.frame); 38 | 39 | rxs_generator_update(&gen); 40 | 41 | // write planes to a file 42 | fwrite((char*)gen.y, gen.ybytes,1, fp); 43 | fwrite((char*)gen.u, gen.ubytes,1, fp); 44 | fwrite((char*)gen.v, gen.vbytes,1, fp); 45 | 46 | if (gen.frame > 250) { 47 | break; 48 | } 49 | 50 | usleep(gen.fps); 51 | } 52 | 53 | fclose(fp); 54 | 55 | rxs_generator_clear(&gen); 56 | 57 | 58 | */ 59 | 60 | #ifndef RXS_GENERATOR_H 61 | #define RXS_GENERATOR_H 62 | 63 | #define RXS_MAX_CHARS 11 64 | #include 65 | 66 | typedef struct rxs_generator rxs_generator; 67 | typedef struct rxs_generator_char rxs_generator_char; 68 | 69 | struct rxs_generator_char { 70 | int id; 71 | int x; 72 | int y; 73 | int width; 74 | int height; 75 | int xoffset; 76 | int yoffset; 77 | int xadvance; 78 | }; 79 | 80 | struct rxs_generator { 81 | uint64_t frame; 82 | uint8_t* y; 83 | uint8_t* u; 84 | uint8_t* v; 85 | uint32_t width; 86 | uint32_t height; 87 | uint32_t ybytes; 88 | uint32_t ubytes; 89 | uint32_t vbytes; 90 | uint32_t nbytes; 91 | int fps_num; 92 | int fps_den; 93 | double fps; /* in microseconds, 1 fps == 1.000.000 us */ 94 | double step; /* used to create the moving bar */ 95 | double perc; /* position of the moving bar */ 96 | rxs_generator_char chars[RXS_MAX_CHARS]; /* bitmap characters, `0-9` and `:` */ 97 | int font_w; 98 | int font_h; 99 | int font_line_height; 100 | }; 101 | 102 | int rxs_generator_init(rxs_generator* g, int width, int height, int fps); 103 | int rxs_generator_update(rxs_generator* g); 104 | int rxs_generator_clear(rxs_generator* g); 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/adapters/libuv.h: -------------------------------------------------------------------------------- 1 | #ifndef __HIREDIS_LIBUV_H__ 2 | #define __HIREDIS_LIBUV_H__ 3 | #include 4 | #include "../hiredis.h" 5 | #include "../async.h" 6 | #include 7 | 8 | typedef struct redisLibuvEvents { 9 | redisAsyncContext* context; 10 | uv_poll_t handle; 11 | int events; 12 | } redisLibuvEvents; 13 | 14 | static int redisLibuvAttach(redisAsyncContext*, uv_loop_t*); 15 | 16 | static void redisLibuvPoll(uv_poll_t* handle, int status, int events) { 17 | redisLibuvEvents* p = (redisLibuvEvents*)handle->data; 18 | 19 | if (status != 0) { 20 | return; 21 | } 22 | 23 | if (events & UV_READABLE) { 24 | redisAsyncHandleRead(p->context); 25 | } 26 | if (events & UV_WRITABLE) { 27 | redisAsyncHandleWrite(p->context); 28 | } 29 | } 30 | 31 | 32 | static void redisLibuvAddRead(void *privdata) { 33 | redisLibuvEvents* p = (redisLibuvEvents*)privdata; 34 | 35 | p->events |= UV_READABLE; 36 | 37 | uv_poll_start(&p->handle, p->events, redisLibuvPoll); 38 | } 39 | 40 | 41 | static void redisLibuvDelRead(void *privdata) { 42 | redisLibuvEvents* p = (redisLibuvEvents*)privdata; 43 | 44 | p->events &= ~UV_READABLE; 45 | 46 | if (p->events) { 47 | uv_poll_start(&p->handle, p->events, redisLibuvPoll); 48 | } else { 49 | uv_poll_stop(&p->handle); 50 | } 51 | } 52 | 53 | 54 | static void redisLibuvAddWrite(void *privdata) { 55 | redisLibuvEvents* p = (redisLibuvEvents*)privdata; 56 | 57 | p->events |= UV_WRITABLE; 58 | 59 | uv_poll_start(&p->handle, p->events, redisLibuvPoll); 60 | } 61 | 62 | 63 | static void redisLibuvDelWrite(void *privdata) { 64 | redisLibuvEvents* p = (redisLibuvEvents*)privdata; 65 | 66 | p->events &= ~UV_WRITABLE; 67 | 68 | if (p->events) { 69 | uv_poll_start(&p->handle, p->events, redisLibuvPoll); 70 | } else { 71 | uv_poll_stop(&p->handle); 72 | } 73 | } 74 | 75 | 76 | static void on_close(uv_handle_t* handle) { 77 | redisLibuvEvents* p = (redisLibuvEvents*)handle->data; 78 | 79 | free(p); 80 | } 81 | 82 | 83 | static void redisLibuvCleanup(void *privdata) { 84 | redisLibuvEvents* p = (redisLibuvEvents*)privdata; 85 | 86 | uv_close((uv_handle_t*)&p->handle, on_close); 87 | } 88 | 89 | 90 | static int redisLibuvAttach(redisAsyncContext* ac, uv_loop_t* loop) { 91 | redisContext *c = &(ac->c); 92 | 93 | if (ac->ev.data != NULL) { 94 | return REDIS_ERR; 95 | } 96 | 97 | ac->ev.addRead = redisLibuvAddRead; 98 | ac->ev.delRead = redisLibuvDelRead; 99 | ac->ev.addWrite = redisLibuvAddWrite; 100 | ac->ev.delWrite = redisLibuvDelWrite; 101 | ac->ev.cleanup = redisLibuvCleanup; 102 | 103 | redisLibuvEvents* p = (redisLibuvEvents*)malloc(sizeof(*p)); 104 | 105 | if (!p) { 106 | return REDIS_ERR; 107 | } 108 | 109 | memset(p, 0, sizeof(*p)); 110 | 111 | if (uv_poll_init(loop, &p->handle, c->fd) != 0) { 112 | return REDIS_ERR; 113 | } 114 | 115 | ac->ev.data = p; 116 | p->handle.data = p; 117 | p->context = ac; 118 | 119 | return REDIS_OK; 120 | } 121 | #endif 122 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/adapters/libuv.h: -------------------------------------------------------------------------------- 1 | #ifndef __HIREDIS_LIBUV_H__ 2 | #define __HIREDIS_LIBUV_H__ 3 | #include 4 | #include "../hiredis.h" 5 | #include "../async.h" 6 | #include 7 | 8 | typedef struct redisLibuvEvents { 9 | redisAsyncContext* context; 10 | uv_poll_t handle; 11 | int events; 12 | } redisLibuvEvents; 13 | 14 | static int redisLibuvAttach(redisAsyncContext*, uv_loop_t*); 15 | 16 | static void redisLibuvPoll(uv_poll_t* handle, int status, int events) { 17 | redisLibuvEvents* p = (redisLibuvEvents*)handle->data; 18 | 19 | if (status != 0) { 20 | return; 21 | } 22 | 23 | if (events & UV_READABLE) { 24 | redisAsyncHandleRead(p->context); 25 | } 26 | if (events & UV_WRITABLE) { 27 | redisAsyncHandleWrite(p->context); 28 | } 29 | } 30 | 31 | 32 | static void redisLibuvAddRead(void *privdata) { 33 | redisLibuvEvents* p = (redisLibuvEvents*)privdata; 34 | 35 | p->events |= UV_READABLE; 36 | 37 | uv_poll_start(&p->handle, p->events, redisLibuvPoll); 38 | } 39 | 40 | 41 | static void redisLibuvDelRead(void *privdata) { 42 | redisLibuvEvents* p = (redisLibuvEvents*)privdata; 43 | 44 | p->events &= ~UV_READABLE; 45 | 46 | if (p->events) { 47 | uv_poll_start(&p->handle, p->events, redisLibuvPoll); 48 | } else { 49 | uv_poll_stop(&p->handle); 50 | } 51 | } 52 | 53 | 54 | static void redisLibuvAddWrite(void *privdata) { 55 | redisLibuvEvents* p = (redisLibuvEvents*)privdata; 56 | 57 | p->events |= UV_WRITABLE; 58 | 59 | uv_poll_start(&p->handle, p->events, redisLibuvPoll); 60 | } 61 | 62 | 63 | static void redisLibuvDelWrite(void *privdata) { 64 | redisLibuvEvents* p = (redisLibuvEvents*)privdata; 65 | 66 | p->events &= ~UV_WRITABLE; 67 | 68 | if (p->events) { 69 | uv_poll_start(&p->handle, p->events, redisLibuvPoll); 70 | } else { 71 | uv_poll_stop(&p->handle); 72 | } 73 | } 74 | 75 | 76 | static void on_close(uv_handle_t* handle) { 77 | redisLibuvEvents* p = (redisLibuvEvents*)handle->data; 78 | 79 | free(p); 80 | } 81 | 82 | 83 | static void redisLibuvCleanup(void *privdata) { 84 | redisLibuvEvents* p = (redisLibuvEvents*)privdata; 85 | 86 | uv_close((uv_handle_t*)&p->handle, on_close); 87 | } 88 | 89 | 90 | static int redisLibuvAttach(redisAsyncContext* ac, uv_loop_t* loop) { 91 | redisContext *c = &(ac->c); 92 | 93 | if (ac->ev.data != NULL) { 94 | return REDIS_ERR; 95 | } 96 | 97 | ac->ev.addRead = redisLibuvAddRead; 98 | ac->ev.delRead = redisLibuvDelRead; 99 | ac->ev.addWrite = redisLibuvAddWrite; 100 | ac->ev.delWrite = redisLibuvDelWrite; 101 | ac->ev.cleanup = redisLibuvCleanup; 102 | 103 | redisLibuvEvents* p = (redisLibuvEvents*)malloc(sizeof(*p)); 104 | 105 | if (!p) { 106 | return REDIS_ERR; 107 | } 108 | 109 | memset(p, 0, sizeof(*p)); 110 | 111 | if (uv_poll_init(loop, &p->handle, c->fd) != 0) { 112 | return REDIS_ERR; 113 | } 114 | 115 | ac->ev.data = p; 116 | p->handle.data = p; 117 | p->context = ac; 118 | 119 | return REDIS_OK; 120 | } 121 | #endif 122 | -------------------------------------------------------------------------------- /src/rxs_streamer/rxs_receiver.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* ----------------------------------------------------------------------------- */ 6 | 7 | static void receiver_alloc_cb(uv_handle_t* handle, size_t nsize, uv_buf_t* buf); 8 | static void receiver_recv_cb(uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags); 9 | 10 | /* ----------------------------------------------------------------------------- */ 11 | 12 | int rxs_receiver_init(rxs_receiver* rec, int port) { 13 | 14 | int r = 0; 15 | 16 | if (!rec) { return -1; } 17 | 18 | /* get the loop handler. */ 19 | rec->loop = uv_default_loop(); 20 | if (!rec->loop) { 21 | printf("Error: cannot get the default uv loop.\n"); 22 | return -2; 23 | } 24 | 25 | /* create sockaddr */ 26 | //r = uv_ip4_addr("0.0.0.0", port, &rec->saddr); 27 | r = uv_ip4_addr("0.0.0.0", port, &rec->saddr); 28 | if (r != 0) { 29 | printf("Error: cannot init the sock struct.\n"); 30 | return -3; 31 | } 32 | 33 | /* init receiver socket. */ 34 | r = uv_udp_init(rec->loop, &rec->recv_sock); 35 | if (r != 0) { 36 | printf("Error: cannot initialize the receive sock handle. %s\n", uv_strerror(r)); 37 | return -4; 38 | } 39 | 40 | /* set the user data */ 41 | rec->recv_sock.data = (void*)rec; 42 | 43 | /* let our sock handle 'listen' on the given port */ 44 | /* @todo - lets rename the sockaddr member to "raddr", r-eceive addr */ 45 | r = uv_udp_bind(&rec->recv_sock, (const struct sockaddr*)&rec->saddr, 0); 46 | if (r != 0) { 47 | printf("Error: cannot bind receiver socket %s\n", uv_strerror(r)); 48 | return -5; 49 | } 50 | 51 | /* start receiving. */ 52 | r = uv_udp_recv_start(&rec->recv_sock, receiver_alloc_cb, receiver_recv_cb); 53 | if (r != 0) { 54 | printf("Error: cannot start the udp receiver: %s\n", uv_strerror(r)); 55 | return -6; 56 | } 57 | 58 | return 0; 59 | } 60 | 61 | void rxs_receiver_update(rxs_receiver* r) { 62 | uv_run(r->loop, UV_RUN_NOWAIT); 63 | //uv_run(r->loop, UV_RUN_DEFAULT); 64 | } 65 | 66 | 67 | /* ----------------------------------------------------------------------------- */ 68 | 69 | static void receiver_alloc_cb(uv_handle_t* handle, 70 | size_t nsize, 71 | uv_buf_t* buf) 72 | { 73 | static char slab[65536]; 74 | 75 | if (nsize > sizeof(slab)) { 76 | printf("Error: requested receiver size to large. @todo - this is just a quick implementation.\n"); 77 | exit(1); 78 | } 79 | 80 | buf->base = slab; 81 | buf->len = sizeof(slab); 82 | } 83 | 84 | static void receiver_recv_cb(uv_udp_t* handle, 85 | ssize_t nread, 86 | const uv_buf_t* buf, 87 | const struct sockaddr* addr, 88 | unsigned int flags) 89 | { 90 | rxs_receiver* rec = (rxs_receiver*) handle->data; 91 | 92 | if (nread == 0) { 93 | /* @todo - how to we handle this ? */ 94 | return ; 95 | } 96 | 97 | rec->on_data(rec, (uint8_t*)buf->base, nread); 98 | } 99 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_depacketizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | rxs_depacketizer 4 | ----------------- 5 | 6 | rxs_depacketizer unwraps RTP VP8 packets and calls the set on_packet 7 | function after it parsed a RTP packet correctly. Note that one frame can 8 | be split over multiple packets. Therefore you need to collect the data 9 | until the marker bit has been set to 1 (see the RTP RFC and e.g. test_vpx). 10 | 11 | */ 12 | #ifndef RXS_DEPACKETIZER_H 13 | #define RXS_DEPACKETIZER_H 14 | 15 | #include 16 | 17 | #define RXS_MAX_FRAME_SIZE (1024 * 1024) /* we expect that the payload data is not more then this */ 18 | 19 | typedef struct rxs_depacketizer rxs_depacketizer; 20 | 21 | typedef void (*rxs_depacketizer_callback)(rxs_depacketizer* dep, uint8_t* buffer, uint32_t nbytes); 22 | 23 | struct rxs_depacketizer { 24 | 25 | /* VP8: header info */ 26 | uint8_t version; 27 | uint8_t padding; 28 | uint8_t extension; 29 | uint8_t csrc_count; 30 | uint8_t marker; /* Set for the very last packet of each encoded frame in line with the normal use of the M bit in video formats. For VP8 this will be set to 1 when the last packet for a frame is received. */ 31 | uint8_t pt; /* Payload */ 32 | uint16_t seqnum; /* Sequence number */ 33 | uint32_t timestamp; 34 | uint32_t ssrc; 35 | 36 | /* VP8: require header */ 37 | uint8_t X; /* extended controlbits present */ 38 | uint8_t N; /* (non-reference frame) when set to 1 this frame can be discarded */ 39 | uint8_t S; /* start of VP8 partition */ 40 | uint8_t PID; /* partition index */ 41 | 42 | /* VP8: 2nd second row Payload Descriptor (is optional) */ 43 | uint8_t I; /* 1 if PictureID is present */ 44 | uint8_t L; /* 1 if TL0PICIDX is present */ 45 | uint8_t T; /* 1 if TID is present */ 46 | uint8_t K; /* 1 if KEYIDX is present */ 47 | uint16_t PictureID; /* 8 or 16 bits, picture ID */ 48 | uint8_t TL0PICIDX; /* 8 bits temporal level zero index */ 49 | 50 | /* state, internal */ 51 | int64_t len; /* number of bytes left in buf */ 52 | uint32_t pos; /* number of bytes in `rxs_depacketizer.buffer` */ 53 | uint8_t* buf; /* current read pointer */ 54 | uint8_t buffer[RXS_MAX_FRAME_SIZE]; 55 | uint8_t received_keyframe; /* is set to 1 when we received a keyframe. only when we received a keyframe we will start calling the on_frame callback */ 56 | 57 | /* callback */ 58 | void* user; 59 | rxs_depacketizer_callback on_packet; /* gets called when we've decoded a rtp vp8 packet */ 60 | }; 61 | 62 | int rxs_depacketizer_init(rxs_depacketizer* dep); 63 | int rxs_depacketizer_reset(rxs_depacketizer* dep); /* just resets the members */ 64 | int rxs_depacketizer_unwrap(rxs_depacketizer* dep, uint8_t* buffer, int64_t nbytes); 65 | void rxs_depacketizer_print(rxs_depacketizer* dep); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/Base.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Base Video Capture 4 | ------------------ 5 | 6 | This base video capture class is an interface for platform specific implementations. 7 | Capabilities describe the features of a capture device, like width/height/fps/pixel_format. 8 | Output Formats describe any build in pixel/codec conversion methods a SDK/OS has (listed with fastest first). 9 | 10 | */ 11 | 12 | #ifndef VIDEO_CAPTURE_BASE_H 13 | #define VIDEO_CAPTURE_BASE_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | namespace ca { 22 | 23 | class Base { 24 | public: 25 | Base(frame_callback fc, void* user); /* Constructor, set the frame callback function which receives the given user pointer. */ 26 | virtual ~Base(); /* Destructor. */ 27 | virtual int open(Settings cfg) = 0; /* Open the device for the given settings object (with device, capability and output format). */ 28 | virtual int close() = 0; /* Close the opened device. */ 29 | virtual int start() = 0; /* Start captureing from the device. */ 30 | virtual int stop() = 0; /* Stop captureing from the device. */ 31 | virtual void update() = 0; /* Update, some implementations need to regurlarly update. Call this at the set FPS speed. */ 32 | virtual std::vector getCapabilities(int device) = 0; /* Retrieve a list with capabilities. */ 33 | virtual std::vector getDevices() = 0; /* Retrieve a list with devices. */ 34 | virtual std::vector getOutputFormats() = 0; /* Some capture SDKs have support for automatic conversion of the raw data it receives from capture devices to more common output values like YUV. */ 35 | 36 | int listDevices(); /* List the available capture devices for the implementation. */ 37 | int listCapabilities(int device); /* List the available capabilities for the given device. */ 38 | int listOutputFormats(); /* List the available output formats the at SDK of the OS/.. supports. On mac these are the output formats of the AVCaptureVideoDataOutput */ 39 | int findCapability(int device, int width, int height, int fmt); /* Get the best matching capability for the given format and dimensions. We return the capability index or -1 if not found. */ 40 | 41 | public: 42 | frame_callback cb_frame; /* The frame callback. */ 43 | void* cb_user; /* The user pointer that is passed into the frame callback. */ 44 | }; 45 | 46 | }; // namespace ca 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/vpx/vpx_frame_buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_FRAME_BUFFER_H_ 12 | #define VPX_VPX_FRAME_BUFFER_H_ 13 | 14 | /*!\file 15 | * \brief Describes the decoder external frame buffer interface. 16 | */ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include "./vpx_integer.h" 23 | 24 | /*!\brief The maximum number of work buffers used by libvpx. 25 | */ 26 | #define VPX_MAXIMUM_WORK_BUFFERS 1 27 | 28 | /*!\brief The maximum number of reference buffers that a VP9 encoder may use. 29 | */ 30 | #define VP9_MAXIMUM_REF_BUFFERS 8 31 | 32 | /*!\brief External frame buffer 33 | * 34 | * This structure holds allocated frame buffers used by the decoder. 35 | */ 36 | typedef struct vpx_codec_frame_buffer { 37 | uint8_t *data; /**< Pointer to the data buffer */ 38 | size_t size; /**< Size of data in bytes */ 39 | void *priv; /**< Frame's private data */ 40 | } vpx_codec_frame_buffer_t; 41 | 42 | /*!\brief get frame buffer callback prototype 43 | * 44 | * This callback is invoked by the decoder to retrieve data for the frame 45 | * buffer in order for the decode call to complete. The callback must 46 | * allocate at least min_size in bytes and assign it to fb->data. Then the 47 | * callback must set fb->size to the allocated size. The application does not 48 | * need to align the allocated data. The callback is triggered when the 49 | * decoder needs a frame buffer to decode a compressed image into. This 50 | * function may be called more than once for every call to vpx_codec_decode. 51 | * The application may set fb->priv to some data which will be passed 52 | * back in the ximage and the release function call. |fb| is guaranteed to 53 | * not be NULL. On success the callback must return 0. Any failure the 54 | * callback must return a value less than 0. 55 | * 56 | * \param[in] priv Callback's private data 57 | * \param[in] new_size Size in bytes needed by the buffer 58 | * \param[in,out] fb Pointer to vpx_codec_frame_buffer_t 59 | */ 60 | typedef int (*vpx_get_frame_buffer_cb_fn_t)( 61 | void *priv, size_t min_size, vpx_codec_frame_buffer_t *fb); 62 | 63 | /*!\brief release frame buffer callback prototype 64 | * 65 | * This callback is invoked by the decoder when the frame buffer is not 66 | * referenced by any other buffers. |fb| is guaranteed to not be NULL. On 67 | * success the callback must return 0. Any failure the callback must return 68 | * a value less than 0. 69 | * 70 | * \param[in] priv Callback's private data 71 | * \param[in] fb Pointer to vpx_codec_frame_buffer_t 72 | */ 73 | typedef int (*vpx_release_frame_buffer_cb_fn_t)( 74 | void *priv, vpx_codec_frame_buffer_t *fb); 75 | 76 | #ifdef __cplusplus 77 | } // extern "C" 78 | #endif 79 | 80 | #endif // VPX_VPX_FRAME_BUFFER_H_ 81 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/Base.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Base Video Capture 4 | ------------------ 5 | 6 | This base video capture class is an interface for platform specific implementations. 7 | Capabilities describe the features of a capture device, like width/height/fps/pixel_format. 8 | Output Formats describe any build in pixel/codec conversion methods a SDK/OS has (listed with fastest first). 9 | 10 | */ 11 | 12 | #ifndef VIDEO_CAPTURE_BASE_H 13 | #define VIDEO_CAPTURE_BASE_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | namespace ca { 22 | 23 | class Base { 24 | public: 25 | Base(frame_callback fc, void* user); /* Constructor, set the frame callback function which receives the given user pointer. */ 26 | virtual ~Base(); /* Destructor. */ 27 | virtual int open(Settings cfg) = 0; /* Open the device for the given settings object (with device, capability and output format). */ 28 | virtual int close() = 0; /* Close the opened device. */ 29 | virtual int start() = 0; /* Start captureing from the device. */ 30 | virtual int stop() = 0; /* Stop captureing from the device. */ 31 | virtual void update() = 0; /* Update, some implementations need to regurlarly update. Call this at the set FPS speed. */ 32 | virtual std::vector getCapabilities(int device) = 0; /* Retrieve a list with capabilities. */ 33 | virtual std::vector getDevices() = 0; /* Retrieve a list with devices. */ 34 | virtual std::vector getOutputFormats() = 0; /* Some capture SDKs have support for automatic conversion of the raw data it receives from capture devices to more common output values like YUV. */ 35 | 36 | int listDevices(); /* List the available capture devices for the implementation. */ 37 | int listCapabilities(int device); /* List the available capabilities for the given device. */ 38 | int listOutputFormats(); /* List the available output formats the at SDK of the OS/.. supports. On mac these are the output formats of the AVCaptureVideoDataOutput */ 39 | int findCapability(int device, int width, int height, int fmt); /* Get the best matching capability for the given format and dimensions. We return the capability index or -1 if not found. */ 40 | 41 | public: 42 | frame_callback cb_frame; /* The frame callback. */ 43 | void* cb_user; /* The user pointer that is passed into the frame callback. */ 44 | }; 45 | 46 | }; // namespace ca 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/vpx/vpx_frame_buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef VPX_VPX_FRAME_BUFFER_H_ 12 | #define VPX_VPX_FRAME_BUFFER_H_ 13 | 14 | /*!\file 15 | * \brief Describes the decoder external frame buffer interface. 16 | */ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include "./vpx_integer.h" 23 | 24 | /*!\brief The maximum number of work buffers used by libvpx. 25 | */ 26 | #define VPX_MAXIMUM_WORK_BUFFERS 1 27 | 28 | /*!\brief The maximum number of reference buffers that a VP9 encoder may use. 29 | */ 30 | #define VP9_MAXIMUM_REF_BUFFERS 8 31 | 32 | /*!\brief External frame buffer 33 | * 34 | * This structure holds allocated frame buffers used by the decoder. 35 | */ 36 | typedef struct vpx_codec_frame_buffer { 37 | uint8_t *data; /**< Pointer to the data buffer */ 38 | size_t size; /**< Size of data in bytes */ 39 | void *priv; /**< Frame's private data */ 40 | } vpx_codec_frame_buffer_t; 41 | 42 | /*!\brief get frame buffer callback prototype 43 | * 44 | * This callback is invoked by the decoder to retrieve data for the frame 45 | * buffer in order for the decode call to complete. The callback must 46 | * allocate at least min_size in bytes and assign it to fb->data. Then the 47 | * callback must set fb->size to the allocated size. The application does not 48 | * need to align the allocated data. The callback is triggered when the 49 | * decoder needs a frame buffer to decode a compressed image into. This 50 | * function may be called more than once for every call to vpx_codec_decode. 51 | * The application may set fb->priv to some data which will be passed 52 | * back in the ximage and the release function call. |fb| is guaranteed to 53 | * not be NULL. On success the callback must return 0. Any failure the 54 | * callback must return a value less than 0. 55 | * 56 | * \param[in] priv Callback's private data 57 | * \param[in] new_size Size in bytes needed by the buffer 58 | * \param[in,out] fb Pointer to vpx_codec_frame_buffer_t 59 | */ 60 | typedef int (*vpx_get_frame_buffer_cb_fn_t)( 61 | void *priv, size_t min_size, vpx_codec_frame_buffer_t *fb); 62 | 63 | /*!\brief release frame buffer callback prototype 64 | * 65 | * This callback is invoked by the decoder when the frame buffer is not 66 | * referenced by any other buffers. |fb| is guaranteed to not be NULL. On 67 | * success the callback must return 0. Any failure the callback must return 68 | * a value less than 0. 69 | * 70 | * \param[in] priv Callback's private data 71 | * \param[in] fb Pointer to vpx_codec_frame_buffer_t 72 | */ 73 | typedef int (*vpx_release_frame_buffer_cb_fn_t)( 74 | void *priv, vpx_codec_frame_buffer_t *fb); 75 | 76 | #ifdef __cplusplus 77 | } // extern "C" 78 | #endif 79 | 80 | #endif // VPX_VPX_FRAME_BUFFER_H_ 81 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/libyuv/scale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_SCALE_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_SCALE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Supported filtering. 22 | enum FilterMode { 23 | kFilterNone = 0, // Point sample; Fastest. 24 | kFilterLinear = 1, // Filter horizontally only. 25 | kFilterBilinear = 2, // Faster than box, but lower quality scaling down. 26 | kFilterBox = 3 // Highest quality. 27 | }; 28 | 29 | // Scale a YUV plane. 30 | LIBYUV_API 31 | void ScalePlane(const uint8* src, int src_stride, 32 | int src_width, int src_height, 33 | uint8* dst, int dst_stride, 34 | int dst_width, int dst_height, 35 | enum FilterMode filtering); 36 | 37 | // Scales a YUV 4:2:0 image from the src width and height to the 38 | // dst width and height. 39 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is 40 | // used. This produces basic (blocky) quality at the fastest speed. 41 | // If filtering is kFilterBilinear, interpolation is used to produce a better 42 | // quality image, at the expense of speed. 43 | // If filtering is kFilterBox, averaging is used to produce ever better 44 | // quality image, at further expense of speed. 45 | // Returns 0 if successful. 46 | 47 | LIBYUV_API 48 | int I420Scale(const uint8* src_y, int src_stride_y, 49 | const uint8* src_u, int src_stride_u, 50 | const uint8* src_v, int src_stride_v, 51 | int src_width, int src_height, 52 | uint8* dst_y, int dst_stride_y, 53 | uint8* dst_u, int dst_stride_u, 54 | uint8* dst_v, int dst_stride_v, 55 | int dst_width, int dst_height, 56 | enum FilterMode filtering); 57 | 58 | #ifdef __cplusplus 59 | // Legacy API. Deprecated. 60 | LIBYUV_API 61 | int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, 62 | int src_stride_y, int src_stride_u, int src_stride_v, 63 | int src_width, int src_height, 64 | uint8* dst_y, uint8* dst_u, uint8* dst_v, 65 | int dst_stride_y, int dst_stride_u, int dst_stride_v, 66 | int dst_width, int dst_height, 67 | bool interpolate); 68 | 69 | // Legacy API. Deprecated. 70 | LIBYUV_API 71 | int ScaleOffset(const uint8* src_i420, int src_width, int src_height, 72 | uint8* dst_i420, int dst_width, int dst_height, int dst_yoffset, 73 | bool interpolate); 74 | 75 | // For testing, allow disabling of specialized scalers. 76 | LIBYUV_API 77 | void SetUseReferenceImpl(bool use); 78 | #endif // __cplusplus 79 | 80 | #ifdef __cplusplus 81 | } // extern "C" 82 | } // namespace libyuv 83 | #endif 84 | 85 | #endif // INCLUDE_LIBYUV_SCALE_H_ NOLINT 86 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/uv-darwin.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_DARWIN_H 23 | #define UV_DARWIN_H 24 | 25 | #if defined(__APPLE__) && defined(__MACH__) 26 | # include 27 | # include 28 | # include 29 | # include 30 | # define UV_PLATFORM_SEM_T semaphore_t 31 | #endif 32 | 33 | #define UV_IO_PRIVATE_PLATFORM_FIELDS \ 34 | int rcount; \ 35 | int wcount; \ 36 | 37 | #define UV_PLATFORM_LOOP_FIELDS \ 38 | uv_thread_t cf_thread; \ 39 | void* _cf_reserved; \ 40 | void* cf_state; \ 41 | uv_mutex_t cf_mutex; \ 42 | uv_sem_t cf_sem; \ 43 | void* cf_signals[2]; \ 44 | 45 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 46 | uv__io_t event_watcher; \ 47 | char* realpath; \ 48 | int realpath_len; \ 49 | int cf_flags; \ 50 | uv_async_t* cf_cb; \ 51 | void* cf_events[2]; \ 52 | void* cf_member[2]; \ 53 | int cf_error; \ 54 | uv_mutex_t cf_mutex; \ 55 | 56 | #define UV_STREAM_PRIVATE_PLATFORM_FIELDS \ 57 | void* select; \ 58 | 59 | #define UV_HAVE_KQUEUE 1 60 | 61 | #endif /* UV_DARWIN_H */ 62 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/libyuv/basic_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_BASIC_TYPES_H_ 13 | 14 | #include // for NULL, size_t 15 | 16 | #if defined(__ANDROID__) || (defined(_MSC_VER) && (_MSC_VER < 1600)) 17 | #include // for uintptr_t on x86 18 | #else 19 | #include // for uintptr_t 20 | #endif 21 | 22 | #ifndef GG_LONGLONG 23 | #ifndef INT_TYPES_DEFINED 24 | #define INT_TYPES_DEFINED 25 | #ifdef COMPILER_MSVC 26 | typedef unsigned __int64 uint64; 27 | typedef __int64 int64; 28 | #ifndef INT64_C 29 | #define INT64_C(x) x ## I64 30 | #endif 31 | #ifndef UINT64_C 32 | #define UINT64_C(x) x ## UI64 33 | #endif 34 | #define INT64_F "I64" 35 | #else // COMPILER_MSVC 36 | #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 37 | typedef unsigned long uint64; // NOLINT 38 | typedef long int64; // NOLINT 39 | #ifndef INT64_C 40 | #define INT64_C(x) x ## L 41 | #endif 42 | #ifndef UINT64_C 43 | #define UINT64_C(x) x ## UL 44 | #endif 45 | #define INT64_F "l" 46 | #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 47 | typedef unsigned long long uint64; // NOLINT 48 | typedef long long int64; // NOLINT 49 | #ifndef INT64_C 50 | #define INT64_C(x) x ## LL 51 | #endif 52 | #ifndef UINT64_C 53 | #define UINT64_C(x) x ## ULL 54 | #endif 55 | #define INT64_F "ll" 56 | #endif // __LP64__ 57 | #endif // COMPILER_MSVC 58 | typedef unsigned int uint32; 59 | typedef int int32; 60 | typedef unsigned short uint16; // NOLINT 61 | typedef short int16; // NOLINT 62 | typedef unsigned char uint8; 63 | typedef signed char int8; 64 | #endif // INT_TYPES_DEFINED 65 | #endif // GG_LONGLONG 66 | 67 | // Detect compiler is for x86 or x64. 68 | #if defined(__x86_64__) || defined(_M_X64) || \ 69 | defined(__i386__) || defined(_M_IX86) 70 | #define CPU_X86 1 71 | #endif 72 | // Detect compiler is for ARM. 73 | #if defined(__arm__) || defined(_M_ARM) 74 | #define CPU_ARM 1 75 | #endif 76 | 77 | #ifndef ALIGNP 78 | #define ALIGNP(p, t) \ 79 | (reinterpret_cast(((reinterpret_cast(p) + \ 80 | ((t) - 1)) & ~((t) - 1)))) 81 | #endif 82 | 83 | #if !defined(LIBYUV_API) 84 | #if defined(_WIN32) || defined(__CYGWIN__) 85 | #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) 86 | #define LIBYUV_API __declspec(dllexport) 87 | #elif defined(LIBYUV_USING_SHARED_LIBRARY) 88 | #define LIBYUV_API __declspec(dllimport) 89 | #else 90 | #define LIBYUV_API 91 | #endif // LIBYUV_BUILDING_SHARED_LIBRARY 92 | #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ 93 | (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ 94 | defined(LIBYUV_USING_SHARED_LIBRARY)) 95 | #define LIBYUV_API __attribute__ ((visibility ("default"))) 96 | #else 97 | #define LIBYUV_API 98 | #endif // __GNUC__ 99 | #endif // LIBYUV_API 100 | 101 | // Visual C x86 or GCC little endian. 102 | #if defined(__x86_64__) || defined(_M_X64) || \ 103 | defined(__i386__) || defined(_M_IX86) || \ 104 | defined(__arm__) || defined(_M_ARM) || \ 105 | (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 106 | #define LIBYUV_LITTLE_ENDIAN 107 | #endif 108 | 109 | #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ NOLINT 110 | -------------------------------------------------------------------------------- /include/rxs_streamer/rxs_control.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | rxs_control 4 | ----------- 5 | 6 | rxs_control is used by the receiver of the video stream to 7 | request lost packets or to request new keyframes. This is a 8 | very simple implementation because this whole library is meant 9 | for simple point-to-point video streaming and doesn't need 10 | a full blown "RTCP / RTP Audio/Video Profile with Feedback" 11 | implementation. 12 | 13 | This file implements both the sender, receiver and depacketizer 14 | of control packets.: 15 | 16 | - rxs_control_sender: used to send control packets 17 | - rxs_control_receiver: used to receive and parse packets. 18 | 19 | +----------------+---+---+--------+ 20 | | 0 16 | 17 | 16 * C | bytes 21 | +----------------+---+---+--------+ 22 | | S | T | C | P | meaning 23 | +----------------+---+---+--------+ 24 | 25 | Bytes 0,1: 26 | ---------- 27 | - S: Sequence number of the control packet, 16 bytes, network byte order 28 | 29 | Byte 3: 30 | -------- 31 | - T: Task - 4 bytes 32 | - C: Count - number of sequence numbers, used in case 33 | when the receiver requests some losts packets. 34 | 35 | Bytes 4 ... 36 | ------------ 37 | - Depending on the command, but normally a sequence of 38 | packet sequence numbers. 39 | 40 | 41 | */ 42 | #ifndef RXS_CONTROL_H 43 | #define RXS_CONTROL_H 44 | 45 | #include 46 | #include 47 | #include /* @todo - what?? */ 48 | 49 | #define RXS_CONTROL_MAX_SEQNUM 15 /* we don't allow more then 15 missed packets */ 50 | #define RXS_CONTROL_COMMAND_KEY_FRAME 1 /* command to request a new keyframe */ 51 | #define RXS_CONTROL_COMMAND_RESEND 2 /* command to request resending of missing sequence numbers */ 52 | 53 | typedef struct rxs_control_sender rxs_control_sender; 54 | typedef struct rxs_control_receiver rxs_control_receiver; 55 | typedef struct rxs_control rxs_control; 56 | 57 | typedef void(*rxs_control_receiver_callback)(rxs_control_receiver* rec); /* gets called when we received and parsed a command */ 58 | 59 | struct rxs_control_sender { 60 | 61 | /* networking */ 62 | struct sockaddr_in saddr; 63 | uv_loop_t* loop; 64 | uv_udp_t sock; 65 | uint8_t buffer[2048]; 66 | uint16_t dx; /* offset in the buffer */ 67 | 68 | /* protocol */ 69 | uint16_t nr; /* number of sent commands */ 70 | uint16_t seqnums[RXS_CONTROL_MAX_SEQNUM]; /* can be filled with sequence number you want to request */ 71 | }; 72 | 73 | struct rxs_control_receiver { 74 | 75 | /* networking */ 76 | struct sockaddr_in saddr; 77 | uv_loop_t* loop; 78 | uv_udp_t sock; 79 | 80 | /* protocol */ 81 | uint8_t command; 82 | uint8_t count; 83 | uint16_t nr; 84 | uint16_t seqnums[RXS_CONTROL_MAX_SEQNUM]; 85 | 86 | /* callback */ 87 | void* user; 88 | rxs_control_receiver_callback on_command; 89 | }; 90 | 91 | /* sender interface */ 92 | int rxs_control_sender_init(rxs_control_sender* s, const char* ip, int port); 93 | void rxs_control_sender_update(rxs_control_sender* s); 94 | int rxs_control_sender_request_keyframe(rxs_control_sender* s); 95 | int rxs_control_sender_request_packets(rxs_control_sender* s, uint16_t* seqnums, int num); /* request to resend some packets, this will use the seqnum member */ 96 | 97 | /* receiver interface */ 98 | int rxs_control_receiver_init(rxs_control_receiver* r, int port); 99 | void rxs_control_receiver_update(rxs_control_receiver* r); 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/libyuv/basic_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_BASIC_TYPES_H_ 13 | 14 | #include // for NULL, size_t 15 | 16 | #if defined(__ANDROID__) || (defined(_MSC_VER) && (_MSC_VER < 1600)) 17 | #include // for uintptr_t on x86 18 | #else 19 | #include // for uintptr_t 20 | #endif 21 | 22 | #ifndef GG_LONGLONG 23 | #ifndef INT_TYPES_DEFINED 24 | #define INT_TYPES_DEFINED 25 | #ifdef COMPILER_MSVC 26 | typedef unsigned __int64 uint64; 27 | typedef __int64 int64; 28 | #ifndef INT64_C 29 | #define INT64_C(x) x ## I64 30 | #endif 31 | #ifndef UINT64_C 32 | #define UINT64_C(x) x ## UI64 33 | #endif 34 | #define INT64_F "I64" 35 | #else // COMPILER_MSVC 36 | #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 37 | typedef unsigned long uint64; // NOLINT 38 | typedef long int64; // NOLINT 39 | #ifndef INT64_C 40 | #define INT64_C(x) x ## L 41 | #endif 42 | #ifndef UINT64_C 43 | #define UINT64_C(x) x ## UL 44 | #endif 45 | #define INT64_F "l" 46 | #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 47 | typedef unsigned long long uint64; // NOLINT 48 | typedef long long int64; // NOLINT 49 | #ifndef INT64_C 50 | #define INT64_C(x) x ## LL 51 | #endif 52 | #ifndef UINT64_C 53 | #define UINT64_C(x) x ## ULL 54 | #endif 55 | #define INT64_F "ll" 56 | #endif // __LP64__ 57 | #endif // COMPILER_MSVC 58 | typedef unsigned int uint32; 59 | typedef int int32; 60 | typedef unsigned short uint16; // NOLINT 61 | typedef short int16; // NOLINT 62 | typedef unsigned char uint8; 63 | typedef signed char int8; 64 | #endif // INT_TYPES_DEFINED 65 | #endif // GG_LONGLONG 66 | 67 | // Detect compiler is for x86 or x64. 68 | #if defined(__x86_64__) || defined(_M_X64) || \ 69 | defined(__i386__) || defined(_M_IX86) 70 | #define CPU_X86 1 71 | #endif 72 | // Detect compiler is for ARM. 73 | #if defined(__arm__) || defined(_M_ARM) 74 | #define CPU_ARM 1 75 | #endif 76 | 77 | #ifndef ALIGNP 78 | #ifdef __cplusplus 79 | #define ALIGNP(p, t) \ 80 | (reinterpret_cast(((reinterpret_cast(p) + \ 81 | ((t) - 1)) & ~((t) - 1)))) 82 | #else 83 | #define ALIGNP(p, t) \ 84 | ((uint8*)((((uintptr_t)(p) + ((t) - 1)) & ~((t) - 1)))) /* NOLINT */ 85 | #endif 86 | #endif 87 | 88 | #if !defined(LIBYUV_API) 89 | #if defined(_WIN32) || defined(__CYGWIN__) 90 | #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) 91 | #define LIBYUV_API __declspec(dllexport) 92 | #elif defined(LIBYUV_USING_SHARED_LIBRARY) 93 | #define LIBYUV_API __declspec(dllimport) 94 | #else 95 | #define LIBYUV_API 96 | #endif // LIBYUV_BUILDING_SHARED_LIBRARY 97 | #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ 98 | (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ 99 | defined(LIBYUV_USING_SHARED_LIBRARY)) 100 | #define LIBYUV_API __attribute__ ((visibility ("default"))) 101 | #else 102 | #define LIBYUV_API 103 | #endif // __GNUC__ 104 | #endif // LIBYUV_API 105 | 106 | #define LIBYUV_BOOL int 107 | #define LIBYUV_FALSE 0 108 | #define LIBYUV_TRUE 1 109 | 110 | // Visual C x86 or GCC little endian. 111 | #if defined(__x86_64__) || defined(_M_X64) || \ 112 | defined(__i386__) || defined(_M_IX86) || \ 113 | defined(__arm__) || defined(_M_ARM) || \ 114 | (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 115 | #define LIBYUV_LITTLE_ENDIAN 116 | #endif 117 | 118 | #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ NOLINT 119 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/vpx/vp8dx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /*!\defgroup vp8_decoder WebM VP8 Decoder 13 | * \ingroup vp8 14 | * 15 | * @{ 16 | */ 17 | /*!\file 18 | * \brief Provides definitions for using the VP8 algorithm within the vpx Decoder 19 | * interface. 20 | */ 21 | #ifndef VPX_VP8DX_H_ 22 | #define VPX_VP8DX_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Include controls common to both the encoder and decoder */ 29 | #include "./vp8.h" 30 | 31 | /*!\name Algorithm interface for VP8 32 | * 33 | * This interface provides the capability to decode raw VP8 streams, as would 34 | * be found in AVI files and other non-Flash uses. 35 | * @{ 36 | */ 37 | extern vpx_codec_iface_t vpx_codec_vp8_dx_algo; 38 | extern vpx_codec_iface_t *vpx_codec_vp8_dx(void); 39 | 40 | /* TODO(jkoleszar): These move to VP9 in a later patch set. */ 41 | extern vpx_codec_iface_t vpx_codec_vp9_dx_algo; 42 | extern vpx_codec_iface_t *vpx_codec_vp9_dx(void); 43 | /*!@} - end algorithm interface member group*/ 44 | 45 | 46 | /*!\enum vp8_dec_control_id 47 | * \brief VP8 decoder control functions 48 | * 49 | * This set of macros define the control functions available for the VP8 50 | * decoder interface. 51 | * 52 | * \sa #vpx_codec_control 53 | */ 54 | enum vp8_dec_control_id { 55 | /** control function to get info on which reference frames were updated 56 | * by the last decode 57 | */ 58 | VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START, 59 | 60 | /** check if the indicated frame is corrupted */ 61 | VP8D_GET_FRAME_CORRUPTED, 62 | 63 | /** control function to get info on which reference frames were used 64 | * by the last decode 65 | */ 66 | VP8D_GET_LAST_REF_USED, 67 | 68 | /** decryption function to decrypt encoded buffer data immediately 69 | * before decoding. Takes a vp8_decrypt_init, which contains 70 | * a callback function and opaque context pointer. 71 | */ 72 | VP8D_SET_DECRYPTOR, 73 | 74 | /** control function to get the display dimensions for the current frame. */ 75 | VP9D_GET_DISPLAY_SIZE, 76 | 77 | /** For testing. */ 78 | VP9_INVERT_TILE_DECODE_ORDER, 79 | 80 | VP8_DECODER_CTRL_ID_MAX 81 | }; 82 | 83 | /*!\brief Structure to hold decryption state 84 | * 85 | * Defines a structure to hold the decryption state and access function. 86 | */ 87 | typedef struct vp8_decrypt_init { 88 | /** Decrypt n bytes of data from input -> output, using the decrypt_state 89 | * passed in VP8D_SET_DECRYPTOR. 90 | */ 91 | void (*decrypt_cb)(void *decrypt_state, const unsigned char *input, 92 | unsigned char *output, int count); 93 | /*! Decryption state. */ 94 | void *decrypt_state; 95 | } vp8_decrypt_init; 96 | 97 | /*!\brief VP8 decoder control function parameter type 98 | * 99 | * Defines the data types that VP8D control functions take. Note that 100 | * additional common controls are defined in vp8.h 101 | * 102 | */ 103 | 104 | 105 | VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *) 106 | VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *) 107 | VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *) 108 | VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vp8_decrypt_init *) 109 | VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *) 110 | VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int) 111 | 112 | /*! @} - end defgroup vp8_decoder */ 113 | 114 | #ifdef __cplusplus 115 | } // extern "C" 116 | #endif 117 | 118 | #endif // VPX_VP8DX_H_ 119 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/win/MediaFoundation_Capture.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MediaFoundation_Capture 4 | ----------------------- 5 | 6 | Implements the Windows Media Foundation capture pipeline to read 7 | frames from capture devices newer Windows PCs (Win7, Win8). If you 8 | want to use this class make sure that you've installed the Windows 9 | SDK. 10 | 11 | - See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms694197(v=vs.85).aspx 12 | - Dependencies: Win SDK 13 | 14 | */ 15 | #ifndef VIDEO_CAPTURE_MEDIA_FOUNDATION_H 16 | #define VIDEO_CAPTURE_MEDIA_FOUNDATION_H 17 | 18 | #include 19 | #include 20 | #include 21 | #include /* e.g. MFEnumDeviceSources */ 22 | #include 23 | #include /* MediaFoundation error codes, MF_E_* */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace ca { 35 | 36 | class MediaFoundation_Capture : public Base { 37 | public: 38 | MediaFoundation_Capture(frame_callback fc, void* user); 39 | ~MediaFoundation_Capture(); 40 | 41 | /* Interface */ 42 | int open(Settings settings); 43 | int close(); 44 | int start(); 45 | int stop(); 46 | void update(); 47 | 48 | /* Capabilities */ 49 | std::vector getCapabilities(int device); /* Get all the capabilities for the given device number */ 50 | std::vector getDevices(); /* We query the udev USB devices. */ 51 | std::vector getOutputFormats(); /* Get the supported output formats. */ 52 | 53 | private: 54 | 55 | /* SDK Capabilities */ 56 | int createSourceReader(IMFMediaSource* mediaSource, IMFSourceReaderCallback* callback, IMFSourceReader** sourceReader); /* Create the IMFSourceReader which is basically an intermediate which allows us to process raw frames ourself. */ 57 | int createVideoDeviceSource(int device, IMFMediaSource** source); /* Creates a new IMFMediaSource object that is activated */ 58 | int getCapabilities(IMFMediaSource* source, std::vector& result); /* Get capabilities for the given source */ 59 | int setDeviceFormat(IMFMediaSource* source, DWORD formatIndex); /* Set the video capture format */ 60 | int setReaderFormat(IMFSourceReader* reader, Capability& cap); /* Set the format for the source reader. The source reader is used to process raw data, see: http://msdn.microsoft.com/en-us/library/windows/desktop/dd940436(v=vs.85).aspx for more information */ 61 | 62 | public: 63 | MediaFoundation_Callback* mf_callback; /* The MediaFoundation_Callback instance that will receive frame data */ 64 | IMFMediaSource* imf_media_source; /* The IMFMediaSource represents the capture device. */ 65 | IMFSourceReader* imf_source_reader; /* The IMFSourceReader is an intermediate that must be used to process raw video frames */ 66 | int state; /* Used to keep track of open/capture state */ 67 | }; 68 | 69 | /* Safely release the given obj. */ 70 | template void safeReleaseMediaFoundation(T **t) { 71 | if(*t) { 72 | (*t)->Release(); 73 | *t = NULL; 74 | } 75 | } 76 | 77 | } // namespace cs 78 | #endif 79 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/win/MediaFoundation_Capture.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MediaFoundation_Capture 4 | ----------------------- 5 | 6 | Implements the Windows Media Foundation capture pipeline to read 7 | frames from capture devices newer Windows PCs (Win7, Win8). If you 8 | want to use this class make sure that you've installed the Windows 9 | SDK. 10 | 11 | - See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms694197(v=vs.85).aspx 12 | - Dependencies: Win SDK 13 | 14 | */ 15 | #ifndef VIDEO_CAPTURE_MEDIA_FOUNDATION_H 16 | #define VIDEO_CAPTURE_MEDIA_FOUNDATION_H 17 | 18 | #include 19 | #include 20 | #include 21 | #include /* e.g. MFEnumDeviceSources */ 22 | #include 23 | #include /* MediaFoundation error codes, MF_E_* */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace ca { 35 | 36 | class MediaFoundation_Capture : public Base { 37 | public: 38 | MediaFoundation_Capture(frame_callback fc, void* user); 39 | ~MediaFoundation_Capture(); 40 | 41 | /* Interface */ 42 | int open(Settings settings); 43 | int close(); 44 | int start(); 45 | int stop(); 46 | void update(); 47 | 48 | /* Capabilities */ 49 | std::vector getCapabilities(int device); /* Get all the capabilities for the given device number */ 50 | std::vector getDevices(); /* We query the udev USB devices. */ 51 | std::vector getOutputFormats(); /* Get the supported output formats. */ 52 | 53 | private: 54 | 55 | /* SDK Capabilities */ 56 | int createSourceReader(IMFMediaSource* mediaSource, IMFSourceReaderCallback* callback, IMFSourceReader** sourceReader); /* Create the IMFSourceReader which is basically an intermediate which allows us to process raw frames ourself. */ 57 | int createVideoDeviceSource(int device, IMFMediaSource** source); /* Creates a new IMFMediaSource object that is activated */ 58 | int getCapabilities(IMFMediaSource* source, std::vector& result); /* Get capabilities for the given source */ 59 | int setDeviceFormat(IMFMediaSource* source, DWORD formatIndex); /* Set the video capture format */ 60 | int setReaderFormat(IMFSourceReader* reader, Capability& cap); /* Set the format for the source reader. The source reader is used to process raw data, see: http://msdn.microsoft.com/en-us/library/windows/desktop/dd940436(v=vs.85).aspx for more information */ 61 | 62 | public: 63 | MediaFoundation_Callback* mf_callback; /* The MediaFoundation_Callback instance that will receive frame data */ 64 | IMFMediaSource* imf_media_source; /* The IMFMediaSource represents the capture device. */ 65 | IMFSourceReader* imf_source_reader; /* The IMFSourceReader is an intermediate that must be used to process raw video frames */ 66 | int state; /* Used to keep track of open/capture state */ 67 | }; 68 | 69 | /* Safely release the given obj. */ 70 | template void safeReleaseMediaFoundation(T **t) { 71 | if(*t) { 72 | (*t)->Release(); 73 | *t = NULL; 74 | } 75 | } 76 | 77 | } // namespace cs 78 | #endif 79 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/libyuv/scale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_SCALE_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_SCALE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Supported filtering. 22 | typedef enum FilterMode { 23 | kFilterNone = 0, // Point sample; Fastest. 24 | kFilterLinear = 1, // Filter horizontally only. 25 | kFilterBilinear = 2, // Faster than box, but lower quality scaling down. 26 | kFilterBox = 3 // Highest quality. 27 | } FilterModeEnum; 28 | 29 | // Scale a YUV plane. 30 | LIBYUV_API 31 | void ScalePlane(const uint8* src, int src_stride, 32 | int src_width, int src_height, 33 | uint8* dst, int dst_stride, 34 | int dst_width, int dst_height, 35 | enum FilterMode filtering); 36 | 37 | void ScalePlane_16(const uint16* src, int src_stride, 38 | int src_width, int src_height, 39 | uint16* dst, int dst_stride, 40 | int dst_width, int dst_height, 41 | enum FilterMode filtering); 42 | 43 | // Scales a YUV 4:2:0 image from the src width and height to the 44 | // dst width and height. 45 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is 46 | // used. This produces basic (blocky) quality at the fastest speed. 47 | // If filtering is kFilterBilinear, interpolation is used to produce a better 48 | // quality image, at the expense of speed. 49 | // If filtering is kFilterBox, averaging is used to produce ever better 50 | // quality image, at further expense of speed. 51 | // Returns 0 if successful. 52 | 53 | LIBYUV_API 54 | int I420Scale(const uint8* src_y, int src_stride_y, 55 | const uint8* src_u, int src_stride_u, 56 | const uint8* src_v, int src_stride_v, 57 | int src_width, int src_height, 58 | uint8* dst_y, int dst_stride_y, 59 | uint8* dst_u, int dst_stride_u, 60 | uint8* dst_v, int dst_stride_v, 61 | int dst_width, int dst_height, 62 | enum FilterMode filtering); 63 | 64 | LIBYUV_API 65 | int I420Scale_16(const uint16* src_y, int src_stride_y, 66 | const uint16* src_u, int src_stride_u, 67 | const uint16* src_v, int src_stride_v, 68 | int src_width, int src_height, 69 | uint16* dst_y, int dst_stride_y, 70 | uint16* dst_u, int dst_stride_u, 71 | uint16* dst_v, int dst_stride_v, 72 | int dst_width, int dst_height, 73 | enum FilterMode filtering); 74 | 75 | #ifdef __cplusplus 76 | // Legacy API. Deprecated. 77 | LIBYUV_API 78 | int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, 79 | int src_stride_y, int src_stride_u, int src_stride_v, 80 | int src_width, int src_height, 81 | uint8* dst_y, uint8* dst_u, uint8* dst_v, 82 | int dst_stride_y, int dst_stride_u, int dst_stride_v, 83 | int dst_width, int dst_height, 84 | LIBYUV_BOOL interpolate); 85 | 86 | // Legacy API. Deprecated. 87 | LIBYUV_API 88 | int ScaleOffset(const uint8* src_i420, int src_width, int src_height, 89 | uint8* dst_i420, int dst_width, int dst_height, int dst_yoffset, 90 | LIBYUV_BOOL interpolate); 91 | 92 | // For testing, allow disabling of specialized scalers. 93 | LIBYUV_API 94 | void SetUseReferenceImpl(LIBYUV_BOOL use); 95 | #endif // __cplusplus 96 | 97 | #ifdef __cplusplus 98 | } // extern "C" 99 | } // namespace libyuv 100 | #endif 101 | 102 | #endif // INCLUDE_LIBYUV_SCALE_H_ NOLINT 103 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/vpx/vp8dx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /*!\defgroup vp8_decoder WebM VP8 Decoder 13 | * \ingroup vp8 14 | * 15 | * @{ 16 | */ 17 | /*!\file 18 | * \brief Provides definitions for using the VP8 algorithm within the vpx Decoder 19 | * interface. 20 | */ 21 | #ifndef VPX_VP8DX_H_ 22 | #define VPX_VP8DX_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Include controls common to both the encoder and decoder */ 29 | #include "./vp8.h" 30 | 31 | /*!\name Algorithm interface for VP8 32 | * 33 | * This interface provides the capability to decode raw VP8 streams, as would 34 | * be found in AVI files and other non-Flash uses. 35 | * @{ 36 | */ 37 | extern vpx_codec_iface_t vpx_codec_vp8_dx_algo; 38 | extern vpx_codec_iface_t *vpx_codec_vp8_dx(void); 39 | 40 | /* TODO(jkoleszar): These move to VP9 in a later patch set. */ 41 | extern vpx_codec_iface_t vpx_codec_vp9_dx_algo; 42 | extern vpx_codec_iface_t *vpx_codec_vp9_dx(void); 43 | /*!@} - end algorithm interface member group*/ 44 | 45 | 46 | /*!\enum vp8_dec_control_id 47 | * \brief VP8 decoder control functions 48 | * 49 | * This set of macros define the control functions available for the VP8 50 | * decoder interface. 51 | * 52 | * \sa #vpx_codec_control 53 | */ 54 | enum vp8_dec_control_id { 55 | /** control function to get info on which reference frames were updated 56 | * by the last decode 57 | */ 58 | VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START, 59 | 60 | /** check if the indicated frame is corrupted */ 61 | VP8D_GET_FRAME_CORRUPTED, 62 | 63 | /** control function to get info on which reference frames were used 64 | * by the last decode 65 | */ 66 | VP8D_GET_LAST_REF_USED, 67 | 68 | /** decryption function to decrypt encoded buffer data immediately 69 | * before decoding. Takes a vpx_decrypt_init, which contains 70 | * a callback function and opaque context pointer. 71 | */ 72 | VPXD_SET_DECRYPTOR, 73 | VP8D_SET_DECRYPTOR = VPXD_SET_DECRYPTOR, 74 | 75 | /** control function to get the display dimensions for the current frame. */ 76 | VP9D_GET_DISPLAY_SIZE, 77 | 78 | /** For testing. */ 79 | VP9_INVERT_TILE_DECODE_ORDER, 80 | 81 | VP8_DECODER_CTRL_ID_MAX 82 | }; 83 | 84 | /** Decrypt n bytes of data from input -> output, using the decrypt_state 85 | * passed in VPXD_SET_DECRYPTOR. 86 | */ 87 | typedef void (*vpx_decrypt_cb)(void *decrypt_state, const unsigned char *input, 88 | unsigned char *output, int count); 89 | 90 | /*!\brief Structure to hold decryption state 91 | * 92 | * Defines a structure to hold the decryption state and access function. 93 | */ 94 | typedef struct vpx_decrypt_init { 95 | /*! Decrypt callback. */ 96 | vpx_decrypt_cb decrypt_cb; 97 | 98 | /*! Decryption state. */ 99 | void *decrypt_state; 100 | } vpx_decrypt_init; 101 | 102 | /*!\brief A deprecated alias for vpx_decrypt_init. 103 | */ 104 | typedef vpx_decrypt_init vp8_decrypt_init; 105 | 106 | 107 | /*!\brief VP8 decoder control function parameter type 108 | * 109 | * Defines the data types that VP8D control functions take. Note that 110 | * additional common controls are defined in vp8.h 111 | * 112 | */ 113 | 114 | 115 | VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *) 116 | VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *) 117 | VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *) 118 | VPX_CTRL_USE_TYPE(VPXD_SET_DECRYPTOR, vpx_decrypt_init *) 119 | VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vpx_decrypt_init *) 120 | VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *) 121 | VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int) 122 | 123 | /*! @} - end defgroup vp8_decoder */ 124 | 125 | #ifdef __cplusplus 126 | } // extern "C" 127 | #endif 128 | 129 | #endif // VPX_VP8DX_H_ 130 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/videocapture/linux/V4L2_Capture.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | V4L2_Capture 4 | ------------ 5 | 6 | Video4Linux2 Capture wrapper. 7 | 8 | */ 9 | #ifndef VIDEO_CAPTURE_V4L2_CAPTURE_H 10 | #define VIDEO_CAPTURE_V4L2_CAPTURE_H 11 | 12 | extern "C" { 13 | # include 14 | # include 15 | # include 16 | # include 17 | # include 18 | # include 19 | # include 20 | # include 21 | # include 22 | # include 23 | # include 24 | # include 25 | # include 26 | } 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace ca { 37 | 38 | int v4l2_ioctl(int fh, int request, void* arg); /* Wrapper around ioctl */ 39 | 40 | class V4L2_Capture : public Base { 41 | 42 | public: 43 | V4L2_Capture(frame_callback fc, void* user); 44 | ~V4L2_Capture(); 45 | 46 | /* Interface */ 47 | int open(Settings settings); /* Open the given device */ 48 | int close(); /* Close the previously opened device */ 49 | int start(); /* Start captureing */ 50 | int stop(); /* Stop captureing. */ 51 | void update(); /* This should be called at framerate; this will grab a new frame */ 52 | 53 | /* Capabilities */ 54 | std::vector getCapabilities(int device); /* Get all the capabilities for the given device number */ 55 | std::vector getDevices(); /* We query the udev USB devices. */ 56 | std::vector getOutputFormats(); /* Get the supported output formats. For V4L2 this is empty. */ 57 | 58 | /* IO Methods */ 59 | int initializeMMAP(int fd); /* Initialize MMAP I/O for the given file descriptor */ 60 | int shutdownMMAP(); /* Shutdown MMAP and free all buffers. */ 61 | int readFrame(); /* Reads one frame from the device */ 62 | 63 | /* Device related*/ 64 | int openDevice(std::string path); /* Open the device and return a descriptor; path is the device devpat.h */ 65 | int closeDevice(int fd); /* Close the given device descriptor; is use when opening/closing multiple devices to test e.g. capabilities; get info on the devices, etc.. */ 66 | int getDriverInfo(const char* path, V4L2_Device& result); /* Get extra driver info for the given syspath. */ 67 | int setCaptureFormat(int fd, int width, int height, int pixfmt); /* Set the pixel format for the given fd, widht, height and pixfmt. */ 68 | int getDeviceV4L2(int dx, V4L2_Device& result); /* Get the device for the given index */ 69 | int getCapabilityV4L2(int fd, struct v4l2_capability* caps); /* Get a v4l2_capability object for the given fd. */ 70 | std::vector getDevicesV4L2(); /* Get the V4L2 devices */ 71 | 72 | private: 73 | int state; /* We keep track of the open/capture state so we know when to stop/close the device */ 74 | int capture_device_fd; /* File descriptor for the capture device. */ 75 | std::vector buffers; /* The buffer that are used to store the frames from the capture device . */ 76 | 77 | }; 78 | }; // namespace ca 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/videocapture/linux/V4L2_Capture.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | V4L2_Capture 4 | ------------ 5 | 6 | Video4Linux2 Capture wrapper. 7 | 8 | */ 9 | #ifndef VIDEO_CAPTURE_V4L2_CAPTURE_H 10 | #define VIDEO_CAPTURE_V4L2_CAPTURE_H 11 | 12 | extern "C" { 13 | # include 14 | # include 15 | # include 16 | # include 17 | # include 18 | # include 19 | # include 20 | # include 21 | # include 22 | # include 23 | # include 24 | # include 25 | # include 26 | } 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace ca { 37 | 38 | int v4l2_ioctl(int fh, int request, void* arg); /* Wrapper around ioctl */ 39 | 40 | class V4L2_Capture : public Base { 41 | 42 | public: 43 | V4L2_Capture(frame_callback fc, void* user); 44 | ~V4L2_Capture(); 45 | 46 | /* Interface */ 47 | int open(Settings settings); /* Open the given device */ 48 | int close(); /* Close the previously opened device */ 49 | int start(); /* Start captureing */ 50 | int stop(); /* Stop captureing. */ 51 | void update(); /* This should be called at framerate; this will grab a new frame */ 52 | 53 | /* Capabilities */ 54 | std::vector getCapabilities(int device); /* Get all the capabilities for the given device number */ 55 | std::vector getDevices(); /* We query the udev USB devices. */ 56 | std::vector getOutputFormats(); /* Get the supported output formats. For V4L2 this is empty. */ 57 | 58 | /* IO Methods */ 59 | int initializeMMAP(int fd); /* Initialize MMAP I/O for the given file descriptor */ 60 | int shutdownMMAP(); /* Shutdown MMAP and free all buffers. */ 61 | int readFrame(); /* Reads one frame from the device */ 62 | 63 | /* Device related*/ 64 | int openDevice(std::string path); /* Open the device and return a descriptor; path is the device devpat.h */ 65 | int closeDevice(int fd); /* Close the given device descriptor; is use when opening/closing multiple devices to test e.g. capabilities; get info on the devices, etc.. */ 66 | int getDriverInfo(const char* path, V4L2_Device& result); /* Get extra driver info for the given syspath. */ 67 | int setCaptureFormat(int fd, int width, int height, int pixfmt); /* Set the pixel format for the given fd, widht, height and pixfmt. */ 68 | int getDeviceV4L2(int dx, V4L2_Device& result); /* Get the device for the given index */ 69 | int getCapabilityV4L2(int fd, struct v4l2_capability* caps); /* Get a v4l2_capability object for the given fd. */ 70 | std::vector getDevicesV4L2(); /* Get the V4L2 devices */ 71 | 72 | private: 73 | int state; /* We keep track of the open/capture state so we know when to stop/close the device */ 74 | int capture_device_fd; /* File descriptor for the capture device. */ 75 | std::vector buffers; /* The buffer that are used to store the frames from the capture device . */ 76 | 77 | }; 78 | }; // namespace ca 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/libyuv/rotate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_ROTATE_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_ROTATE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Supported rotation. 22 | enum RotationMode { 23 | kRotate0 = 0, // No rotation. 24 | kRotate90 = 90, // Rotate 90 degrees clockwise. 25 | kRotate180 = 180, // Rotate 180 degrees. 26 | kRotate270 = 270, // Rotate 270 degrees clockwise. 27 | 28 | // Deprecated. 29 | kRotateNone = 0, 30 | kRotateClockwise = 90, 31 | kRotateCounterClockwise = 270, 32 | }; 33 | 34 | // Rotate I420 frame. 35 | LIBYUV_API 36 | int I420Rotate(const uint8* src_y, int src_stride_y, 37 | const uint8* src_u, int src_stride_u, 38 | const uint8* src_v, int src_stride_v, 39 | uint8* dst_y, int dst_stride_y, 40 | uint8* dst_u, int dst_stride_u, 41 | uint8* dst_v, int dst_stride_v, 42 | int src_width, int src_height, enum RotationMode mode); 43 | 44 | // Rotate NV12 input and store in I420. 45 | LIBYUV_API 46 | int NV12ToI420Rotate(const uint8* src_y, int src_stride_y, 47 | const uint8* src_uv, int src_stride_uv, 48 | uint8* dst_y, int dst_stride_y, 49 | uint8* dst_u, int dst_stride_u, 50 | uint8* dst_v, int dst_stride_v, 51 | int src_width, int src_height, enum RotationMode mode); 52 | 53 | // Rotate a plane by 0, 90, 180, or 270. 54 | LIBYUV_API 55 | int RotatePlane(const uint8* src, int src_stride, 56 | uint8* dst, int dst_stride, 57 | int src_width, int src_height, enum RotationMode mode); 58 | 59 | // Rotate planes by 90, 180, 270. Deprecated. 60 | LIBYUV_API 61 | void RotatePlane90(const uint8* src, int src_stride, 62 | uint8* dst, int dst_stride, 63 | int width, int height); 64 | 65 | LIBYUV_API 66 | void RotatePlane180(const uint8* src, int src_stride, 67 | uint8* dst, int dst_stride, 68 | int width, int height); 69 | 70 | LIBYUV_API 71 | void RotatePlane270(const uint8* src, int src_stride, 72 | uint8* dst, int dst_stride, 73 | int width, int height); 74 | 75 | LIBYUV_API 76 | void RotateUV90(const uint8* src, int src_stride, 77 | uint8* dst_a, int dst_stride_a, 78 | uint8* dst_b, int dst_stride_b, 79 | int width, int height); 80 | 81 | // Rotations for when U and V are interleaved. 82 | // These functions take one input pointer and 83 | // split the data into two buffers while 84 | // rotating them. Deprecated. 85 | LIBYUV_API 86 | void RotateUV180(const uint8* src, int src_stride, 87 | uint8* dst_a, int dst_stride_a, 88 | uint8* dst_b, int dst_stride_b, 89 | int width, int height); 90 | 91 | LIBYUV_API 92 | void RotateUV270(const uint8* src, int src_stride, 93 | uint8* dst_a, int dst_stride_a, 94 | uint8* dst_b, int dst_stride_b, 95 | int width, int height); 96 | 97 | // The 90 and 270 functions are based on transposes. 98 | // Doing a transpose with reversing the read/write 99 | // order will result in a rotation by +- 90 degrees. 100 | // Deprecated. 101 | LIBYUV_API 102 | void TransposePlane(const uint8* src, int src_stride, 103 | uint8* dst, int dst_stride, 104 | int width, int height); 105 | 106 | LIBYUV_API 107 | void TransposeUV(const uint8* src, int src_stride, 108 | uint8* dst_a, int dst_stride_a, 109 | uint8* dst_b, int dst_stride_b, 110 | int width, int height); 111 | 112 | #ifdef __cplusplus 113 | } // extern "C" 114 | } // namespace libyuv 115 | #endif 116 | 117 | #endif // INCLUDE_LIBYUV_ROTATE_H_ NOLINT 118 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/libyuv/rotate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_ROTATE_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_ROTATE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Supported rotation. 22 | typedef enum RotationMode { 23 | kRotate0 = 0, // No rotation. 24 | kRotate90 = 90, // Rotate 90 degrees clockwise. 25 | kRotate180 = 180, // Rotate 180 degrees. 26 | kRotate270 = 270, // Rotate 270 degrees clockwise. 27 | 28 | // Deprecated. 29 | kRotateNone = 0, 30 | kRotateClockwise = 90, 31 | kRotateCounterClockwise = 270, 32 | } RotationModeEnum; 33 | 34 | // Rotate I420 frame. 35 | LIBYUV_API 36 | int I420Rotate(const uint8* src_y, int src_stride_y, 37 | const uint8* src_u, int src_stride_u, 38 | const uint8* src_v, int src_stride_v, 39 | uint8* dst_y, int dst_stride_y, 40 | uint8* dst_u, int dst_stride_u, 41 | uint8* dst_v, int dst_stride_v, 42 | int src_width, int src_height, enum RotationMode mode); 43 | 44 | // Rotate NV12 input and store in I420. 45 | LIBYUV_API 46 | int NV12ToI420Rotate(const uint8* src_y, int src_stride_y, 47 | const uint8* src_uv, int src_stride_uv, 48 | uint8* dst_y, int dst_stride_y, 49 | uint8* dst_u, int dst_stride_u, 50 | uint8* dst_v, int dst_stride_v, 51 | int src_width, int src_height, enum RotationMode mode); 52 | 53 | // Rotate a plane by 0, 90, 180, or 270. 54 | LIBYUV_API 55 | int RotatePlane(const uint8* src, int src_stride, 56 | uint8* dst, int dst_stride, 57 | int src_width, int src_height, enum RotationMode mode); 58 | 59 | // Rotate planes by 90, 180, 270. Deprecated. 60 | LIBYUV_API 61 | void RotatePlane90(const uint8* src, int src_stride, 62 | uint8* dst, int dst_stride, 63 | int width, int height); 64 | 65 | LIBYUV_API 66 | void RotatePlane180(const uint8* src, int src_stride, 67 | uint8* dst, int dst_stride, 68 | int width, int height); 69 | 70 | LIBYUV_API 71 | void RotatePlane270(const uint8* src, int src_stride, 72 | uint8* dst, int dst_stride, 73 | int width, int height); 74 | 75 | LIBYUV_API 76 | void RotateUV90(const uint8* src, int src_stride, 77 | uint8* dst_a, int dst_stride_a, 78 | uint8* dst_b, int dst_stride_b, 79 | int width, int height); 80 | 81 | // Rotations for when U and V are interleaved. 82 | // These functions take one input pointer and 83 | // split the data into two buffers while 84 | // rotating them. Deprecated. 85 | LIBYUV_API 86 | void RotateUV180(const uint8* src, int src_stride, 87 | uint8* dst_a, int dst_stride_a, 88 | uint8* dst_b, int dst_stride_b, 89 | int width, int height); 90 | 91 | LIBYUV_API 92 | void RotateUV270(const uint8* src, int src_stride, 93 | uint8* dst_a, int dst_stride_a, 94 | uint8* dst_b, int dst_stride_b, 95 | int width, int height); 96 | 97 | // The 90 and 270 functions are based on transposes. 98 | // Doing a transpose with reversing the read/write 99 | // order will result in a rotation by +- 90 degrees. 100 | // Deprecated. 101 | LIBYUV_API 102 | void TransposePlane(const uint8* src, int src_stride, 103 | uint8* dst, int dst_stride, 104 | int width, int height); 105 | 106 | LIBYUV_API 107 | void TransposeUV(const uint8* src, int src_stride, 108 | uint8* dst_a, int dst_stride_a, 109 | uint8* dst_b, int dst_stride_b, 110 | int width, int height); 111 | 112 | #ifdef __cplusplus 113 | } // extern "C" 114 | } // namespace libyuv 115 | #endif 116 | 117 | #endif // INCLUDE_LIBYUV_ROTATE_H_ NOLINT 118 | -------------------------------------------------------------------------------- /extern/linux-gcc-x86_64/include/adapters/libevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2011, Pieter Noordhuis 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of Redis nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef __HIREDIS_LIBEVENT_H__ 32 | #define __HIREDIS_LIBEVENT_H__ 33 | #include 34 | #include "../hiredis.h" 35 | #include "../async.h" 36 | 37 | typedef struct redisLibeventEvents { 38 | redisAsyncContext *context; 39 | struct event rev, wev; 40 | } redisLibeventEvents; 41 | 42 | static void redisLibeventReadEvent(int fd, short event, void *arg) { 43 | ((void)fd); ((void)event); 44 | redisLibeventEvents *e = (redisLibeventEvents*)arg; 45 | redisAsyncHandleRead(e->context); 46 | } 47 | 48 | static void redisLibeventWriteEvent(int fd, short event, void *arg) { 49 | ((void)fd); ((void)event); 50 | redisLibeventEvents *e = (redisLibeventEvents*)arg; 51 | redisAsyncHandleWrite(e->context); 52 | } 53 | 54 | static void redisLibeventAddRead(void *privdata) { 55 | redisLibeventEvents *e = (redisLibeventEvents*)privdata; 56 | event_add(&e->rev,NULL); 57 | } 58 | 59 | static void redisLibeventDelRead(void *privdata) { 60 | redisLibeventEvents *e = (redisLibeventEvents*)privdata; 61 | event_del(&e->rev); 62 | } 63 | 64 | static void redisLibeventAddWrite(void *privdata) { 65 | redisLibeventEvents *e = (redisLibeventEvents*)privdata; 66 | event_add(&e->wev,NULL); 67 | } 68 | 69 | static void redisLibeventDelWrite(void *privdata) { 70 | redisLibeventEvents *e = (redisLibeventEvents*)privdata; 71 | event_del(&e->wev); 72 | } 73 | 74 | static void redisLibeventCleanup(void *privdata) { 75 | redisLibeventEvents *e = (redisLibeventEvents*)privdata; 76 | event_del(&e->rev); 77 | event_del(&e->wev); 78 | free(e); 79 | } 80 | 81 | static int redisLibeventAttach(redisAsyncContext *ac, struct event_base *base) { 82 | redisContext *c = &(ac->c); 83 | redisLibeventEvents *e; 84 | 85 | /* Nothing should be attached when something is already attached */ 86 | if (ac->ev.data != NULL) 87 | return REDIS_ERR; 88 | 89 | /* Create container for context and r/w events */ 90 | e = (redisLibeventEvents*)malloc(sizeof(*e)); 91 | e->context = ac; 92 | 93 | /* Register functions to start/stop listening for events */ 94 | ac->ev.addRead = redisLibeventAddRead; 95 | ac->ev.delRead = redisLibeventDelRead; 96 | ac->ev.addWrite = redisLibeventAddWrite; 97 | ac->ev.delWrite = redisLibeventDelWrite; 98 | ac->ev.cleanup = redisLibeventCleanup; 99 | ac->ev.data = e; 100 | 101 | /* Initialize and install read/write events */ 102 | event_set(&e->rev,c->fd,EV_READ,redisLibeventReadEvent,e); 103 | event_set(&e->wev,c->fd,EV_WRITE,redisLibeventWriteEvent,e); 104 | event_base_set(base,&e->rev); 105 | event_base_set(base,&e->wev); 106 | return REDIS_OK; 107 | } 108 | #endif 109 | -------------------------------------------------------------------------------- /extern/mac-clang-x86_64/include/adapters/libevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2011, Pieter Noordhuis 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of Redis nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef __HIREDIS_LIBEVENT_H__ 32 | #define __HIREDIS_LIBEVENT_H__ 33 | #include 34 | #include "../hiredis.h" 35 | #include "../async.h" 36 | 37 | typedef struct redisLibeventEvents { 38 | redisAsyncContext *context; 39 | struct event rev, wev; 40 | } redisLibeventEvents; 41 | 42 | static void redisLibeventReadEvent(int fd, short event, void *arg) { 43 | ((void)fd); ((void)event); 44 | redisLibeventEvents *e = (redisLibeventEvents*)arg; 45 | redisAsyncHandleRead(e->context); 46 | } 47 | 48 | static void redisLibeventWriteEvent(int fd, short event, void *arg) { 49 | ((void)fd); ((void)event); 50 | redisLibeventEvents *e = (redisLibeventEvents*)arg; 51 | redisAsyncHandleWrite(e->context); 52 | } 53 | 54 | static void redisLibeventAddRead(void *privdata) { 55 | redisLibeventEvents *e = (redisLibeventEvents*)privdata; 56 | event_add(&e->rev,NULL); 57 | } 58 | 59 | static void redisLibeventDelRead(void *privdata) { 60 | redisLibeventEvents *e = (redisLibeventEvents*)privdata; 61 | event_del(&e->rev); 62 | } 63 | 64 | static void redisLibeventAddWrite(void *privdata) { 65 | redisLibeventEvents *e = (redisLibeventEvents*)privdata; 66 | event_add(&e->wev,NULL); 67 | } 68 | 69 | static void redisLibeventDelWrite(void *privdata) { 70 | redisLibeventEvents *e = (redisLibeventEvents*)privdata; 71 | event_del(&e->wev); 72 | } 73 | 74 | static void redisLibeventCleanup(void *privdata) { 75 | redisLibeventEvents *e = (redisLibeventEvents*)privdata; 76 | event_del(&e->rev); 77 | event_del(&e->wev); 78 | free(e); 79 | } 80 | 81 | static int redisLibeventAttach(redisAsyncContext *ac, struct event_base *base) { 82 | redisContext *c = &(ac->c); 83 | redisLibeventEvents *e; 84 | 85 | /* Nothing should be attached when something is already attached */ 86 | if (ac->ev.data != NULL) 87 | return REDIS_ERR; 88 | 89 | /* Create container for context and r/w events */ 90 | e = (redisLibeventEvents*)malloc(sizeof(*e)); 91 | e->context = ac; 92 | 93 | /* Register functions to start/stop listening for events */ 94 | ac->ev.addRead = redisLibeventAddRead; 95 | ac->ev.delRead = redisLibeventDelRead; 96 | ac->ev.addWrite = redisLibeventAddWrite; 97 | ac->ev.delWrite = redisLibeventDelWrite; 98 | ac->ev.cleanup = redisLibeventCleanup; 99 | ac->ev.data = e; 100 | 101 | /* Initialize and install read/write events */ 102 | event_set(&e->rev,c->fd,EV_READ,redisLibeventReadEvent,e); 103 | event_set(&e->wev,c->fd,EV_WRITE,redisLibeventWriteEvent,e); 104 | event_base_set(base,&e->rev); 105 | event_base_set(base,&e->wev); 106 | return REDIS_OK; 107 | } 108 | #endif 109 | -------------------------------------------------------------------------------- /src/examples/test_rxs_jitter.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | test_jitter 4 | ----------- 5 | 6 | Testing rxs_jitter. 7 | 8 | References: 9 | ----------- 10 | 11 | Experimenting with packet loss can done using the `tc` util on linux. See 12 | this SO for some info http://stackoverflow.com/questions/614795/simulate-delayed-and-dropped-packets-on-linux 13 | 14 | */ 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | static void sigh(int s); 28 | static void on_data(rxs_receiver* r, uint8_t* buf, uint32_t nbytes); 29 | static void on_packet(rxs_depacketizer* d, uint8_t* buffer, uint32_t nbytes); 30 | static void on_missing_seqnum(rxs_jitter* jit, uint16_t* seqnums, int num); 31 | static void on_frame(rxs_jitter* jit, uint8_t* data, uint32_t nbytes); 32 | static void on_jit_packet(rxs_jitter* jit, rxs_packet* pkt); 33 | static void on_vp8_image(rxs_decoder* dec, vpx_image_t* img); 34 | 35 | rxs_jitter jit; 36 | rxs_depacketizer depack; 37 | rxs_receiver receiver; 38 | rxs_decoder decoder; 39 | rxs_control_sender control_sender; 40 | 41 | int main() { 42 | 43 | signal(SIGINT, sigh); 44 | 45 | if (rxs_jitter_init(&jit) < 0) { 46 | printf("Error: cannot init jitter.\n"); 47 | exit(1); 48 | } 49 | 50 | if (rxs_receiver_init(&receiver, 6970) < 0) { 51 | printf("Error: cannot init the receiver.\n"); 52 | exit(1); 53 | } 54 | 55 | if (rxs_depacketizer_init(&depack) < 0) { 56 | printf("Error: cannot init depacketizer.\n"); 57 | exit(1); 58 | } 59 | 60 | if (rxs_decoder_init(&decoder) < 0) { 61 | printf("Error: cannot init decoder.\n"); 62 | exit(1); 63 | } 64 | 65 | //if (rxs_control_sender_init(&control_sender, "192.168.0.190", RXS_CONTROL_PORT) < 0) { 66 | if (rxs_control_sender_init(&control_sender, "0.0.0.0", RXS_CONTROL_PORT) < 0) { 67 | printf("Error: cannot control sender.\n"); 68 | exit(1); 69 | } 70 | 71 | receiver.on_data = on_data; 72 | depack.on_packet = on_packet; 73 | decoder.on_image = on_vp8_image; 74 | jit.on_missing_seqnum = on_missing_seqnum; 75 | jit.on_frame = on_frame; 76 | 77 | while(1) { 78 | rxs_receiver_update(&receiver); 79 | rxs_jitter_update(&jit); 80 | rxs_control_sender_update(&control_sender); 81 | } 82 | 83 | return 0; 84 | } 85 | 86 | static void sigh(int s) { 87 | printf("\nCatched signal.\n"); 88 | exit(1); 89 | } 90 | 91 | static void on_data(rxs_receiver* r, uint8_t* buf, uint32_t nbytes) { 92 | if (rxs_depacketizer_unwrap(&depack, buf, nbytes) < 0) { 93 | printf("Error: cannot unwrap the incoming packet.\n"); 94 | exit(1); 95 | } 96 | } 97 | 98 | static void on_packet(rxs_depacketizer* d, uint8_t* buffer, uint32_t nbytes) { 99 | 100 | /* copy all necessary data for the jitter buffer */ 101 | rxs_packet p; 102 | p.marker = d->marker; 103 | p.timestamp = d->timestamp; 104 | p.seqnum = d->seqnum; // + rand(); 105 | p.data = buffer; 106 | p.nbytes = nbytes; 107 | p.nonref = d->N; 108 | 109 | if (rxs_jitter_add_packet(&jit, &p) < 0) { 110 | printf("Error: could not add a new packet to the jitter buffer.\n"); 111 | exit(1); 112 | } 113 | } 114 | 115 | static void on_missing_seqnum(rxs_jitter* jit, uint16_t* seqnums, int num) { 116 | printf("Missing some sequence numbers: %d\n", num); 117 | rxs_control_sender_request_packets(&control_sender, seqnums, num); 118 | } 119 | 120 | static void on_frame(rxs_jitter* jit, uint8_t* data, uint32_t nbytes) { 121 | if (rxs_decoder_decode(&decoder, data, nbytes) < 0) { 122 | printf("Error: cannot decode.\n"); 123 | exit(1); 124 | } 125 | } 126 | 127 | static void on_jit_packet(rxs_jitter* jit, rxs_packet* pkt) { 128 | 129 | static int had_key = 0; 130 | if (pkt->nonref == 0) { 131 | had_key = 1; 132 | } 133 | 134 | if (!had_key) { 135 | printf("- ignoring pkt, because we're waiting for a keyframe. %d\n", pkt->seqnum); 136 | return; 137 | } 138 | 139 | if (rxs_decoder_decode(&decoder, pkt->data, pkt->nbytes) < 0) { 140 | printf("Error: cannot decode.\n"); 141 | exit(1); 142 | } 143 | } 144 | 145 | static void on_vp8_image(rxs_decoder* dec, vpx_image_t* img) { 146 | // printf("Got a decoded vp8 image.\n"); 147 | } 148 | -------------------------------------------------------------------------------- /src/rxs_streamer/rxs_encoder.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* ----------------------------------------------------------------------------- */ 6 | 7 | void print_vpx_packet(const vpx_codec_cx_pkt_t* pkt); 8 | 9 | /* ----------------------------------------------------------------------------- */ 10 | 11 | int rxs_encoder_init(rxs_encoder* enc, rxs_encoder_config* cfg) { 12 | 13 | vpx_codec_err_t err; 14 | int flags = VPX_CODEC_CAP_OUTPUT_PARTITION; 15 | //flags = VPX_CODEC_USE_OUTPUT_PARTITION; 16 | ///flags = 0; 17 | 18 | /* validate */ 19 | if (!enc) { return -1; } 20 | if (!cfg) { return -2; } 21 | if (!cfg->width) { return -3; } 22 | if (!cfg->height) { return -4; } 23 | 24 | /* initialize the codec */ 25 | err = vpx_codec_enc_config_default(vpx_cx_interface, &enc->cfg, 0); 26 | if (err) { 27 | printf("Error: failed to setup vpx encoder. %s\n", vpx_codec_err_to_string(err)); 28 | return -5; 29 | } 30 | 31 | /* update config */ 32 | enc->cfg.rc_target_bitrate = 300; 33 | enc->cfg.g_w = cfg->width; 34 | enc->cfg.g_h = cfg->height; 35 | enc->cfg.g_timebase.num = 1; 36 | enc->cfg.g_timebase.den = (int) 1000; 37 | 38 | 39 | /* @todo - copied these settings from: https://github.com/3XX0/rtvs/blob/master/encode.c , have to verify/test those */ 40 | #if 1 41 | enc->cfg.g_pass = VPX_RC_ONE_PASS; 42 | enc->cfg.g_error_resilient = 1; 43 | enc->cfg.kf_mode = VPX_KF_AUTO; 44 | enc->cfg.g_lag_in_frames = 0; 45 | enc->cfg.rc_dropframe_thresh = 1; 46 | enc->cfg.rc_end_usage = VPX_CBR; 47 | #endif 48 | 49 | #if 0 50 | enc->cfg.kf_mode = VPX_KF_AUTO; 51 | enc->cfg.g_lag_in_frames = 0; 52 | enc->cfg.rc_dropframe_thresh = 1; 53 | enc->cfg.rc_end_usage = VPX_CBR; 54 | enc->cfg.rc_buf_sz = 6000; 55 | enc->cfg.rc_buf_initial_sz = 4000; 56 | enc->cfg.rc_buf_optimal_sz = 5000; 57 | #endif 58 | 59 | /* init codec */ 60 | err = vpx_codec_enc_init(&enc->ctx, vpx_cx_interface, &enc->cfg, flags); 61 | if (err) { 62 | printf("Error: could not initialize the vpx encoder: %s\n", vpx_codec_err_to_string(err)); 63 | return -6; 64 | } 65 | 66 | /* copy some info from the config that we need */ 67 | enc->width = cfg->width; 68 | enc->height = cfg->height; 69 | enc->fps_num = cfg->fps_num; 70 | enc->fps_den = cfg->fps_den; 71 | enc->fmt = cfg->fmt; 72 | 73 | /* @todo - is this correct? */ 74 | enc->frame_duration = ((double) 1.0 / cfg->fps_den) / ((double) enc->cfg.g_timebase.num / enc->cfg.g_timebase.den); 75 | 76 | return 0; 77 | } 78 | 79 | int rxs_encoder_encode(rxs_encoder* enc, unsigned char* pixels, int64_t pts) { 80 | 81 | vpx_codec_err_t err; 82 | vpx_image_t* img = NULL; 83 | vpx_codec_iter_t iter = NULL; 84 | const vpx_codec_cx_pkt_t* pkt; 85 | 86 | if (!enc) { return -1; } 87 | if (!pixels) { return -2; } 88 | 89 | img = vpx_img_wrap(&enc->img, enc->fmt, enc->width, enc->height, 1, pixels); 90 | if (!img) { 91 | printf("Error: cannot wrap the image.\n"); 92 | return -4; 93 | } 94 | 95 | err = vpx_codec_encode(&enc->ctx, img, pts, enc->frame_duration, enc->flags, VPX_DL_REALTIME); 96 | if (err) { 97 | printf("Error: while encoding.\n"); 98 | return -5; 99 | } 100 | 101 | while ( (pkt = vpx_codec_get_cx_data(&enc->ctx, &iter)) ) { 102 | if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) { 103 | enc->on_packet(enc, pkt, pts); 104 | } 105 | } 106 | 107 | enc->flags = 0; 108 | 109 | return 0; 110 | } 111 | 112 | int rxs_encoder_request_keyframe(rxs_encoder* enc) { 113 | if (!enc) { return -1; } 114 | enc->flags |= VPX_EFLAG_FORCE_KF; 115 | 116 | return 0; 117 | } 118 | 119 | /* ----------------------------------------------------------------------------- */ 120 | 121 | void print_vpx_packet(const vpx_codec_cx_pkt_t* pkt) { 122 | 123 | if (!pkt) { return ; } 124 | 125 | if (pkt->data.frame.partition_id == 0) { 126 | printf("-------\n"); 127 | } 128 | 129 | printf("pkt.frame.sz: %zu\n", pkt->data.frame.sz); 130 | printf("pkt.frame.pts: %lld\n", pkt->data.frame.pts); 131 | printf("pkt.frame.duration: %lu\n", pkt->data.frame.duration); 132 | printf("pkt.frame.flags: %d\n", pkt->data.frame.flags); 133 | printf("pkt.frame.partition_id: %d\n", pkt->data.frame.partition_id); 134 | printf("pkt.frame.flags (VPX_FRAME_IS_FRAGMENT): %d\n", pkt->data.frame.flags & VPX_FRAME_IS_FRAGMENT); 135 | printf("+\n"); 136 | } 137 | 138 | /* ----------------------------------------------------------------------------- */ 139 | --------------------------------------------------------------------------------