diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-07-21 14:55:25 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-07-21 14:55:25 +0000 |
| commit | 5e1e6ee15ed99237b169d65aa79f9e48e0ba34ef (patch) | |
| tree | 74f0d15947c043b62a74e7392570f40449034107 | |
| download | obs-bmusb-5e1e6ee15ed99237b169d65aa79f9e48e0ba34ef.tar.gz obs-bmusb-5e1e6ee15ed99237b169d65aa79f9e48e0ba34ef.zip | |
initial commit - WIP
| -rw-r--r-- | CMakeLists.txt | 18 | ||||
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | bmusb-source.cpp | 84 |
3 files changed, 110 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..84bae25 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +project(obs-bmusb) + +set(obs-bmusb_SOURCES + bmusb-source.cpp) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(BMUSB REQUIRED bmusb) + +add_library(obs-bmusb MODULE + ${obs-bmusb_SOURCES}) +target_include_directories(obs-bmusb PUBLIC + ${BMUSB_INCLUDE_DIRS}) +target_link_libraries(obs-bmusb + libobs + bmusb + ${BMUSB_LIBRARIES}) + +install_obs_plugin_with_data(obs-bmusb data) diff --git a/README.md b/README.md new file mode 100644 index 0000000..ed62e3a --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +obs-bmusb +========= +`obs-bmusb` is a Linux plugin for [OBS studio][obs] that provides a Source for capturing from the BlackMagic USB3 cards +Intensity Shuttle and UltraStudio SDI via the [bmusb][bmusb] driver. + + +[obs]: https://obsproject.com/ +[bmusb]: https://git.sesse.net/?p=bmusb;a=summary diff --git a/bmusb-source.cpp b/bmusb-source.cpp new file mode 100644 index 0000000..47ec09b --- /dev/null +++ b/bmusb-source.cpp @@ -0,0 +1,84 @@ +#include <stdlib.h> +#include <obs.h> +#include <obs-module.h> +#include <bmusb/bmusb.h> + +#include <stdio.h> + +using bmusb::BMUSBCapture; +using bmusb::FrameAllocator; +using bmusb::VideoFormat; +using bmusb::AudioFormat; + +struct bmusb_inst { + obs_source_t *source; + BMUSBCapture *capture; + bool initialized; +}; + +static const char *bmusb_getname(void *unused) +{ + UNUSED_PARAMETER(unused); + return "Blackmagic USB3 source (bmusb)"; +} + +static void bmusb_destroy(void *data) +{ + struct bmusb_inst *rt = (bmusb_inst *) data; + + if (rt) { + if (rt->initialized) { + BMUSBCapture::stop_bm_thread(); + delete rt->capture; + } + + bfree(rt); + } +} + +static void *bmusb_create(obs_data_t *settings, obs_source_t *source) +{ + struct bmusb_inst *rt = (bmusb_inst *) bzalloc(sizeof(struct bmusb_inst)); + rt->source = source; + + rt->capture = new BMUSBCapture(0); // @TODO select card + rt->capture->set_pixel_format(bmusb::PixelFormat_8BitYCbCr); + rt->capture->set_frame_callback( + [rt](uint16_t timecode, + FrameAllocator::Frame video_frame, size_t video_offset, VideoFormat video_format, + FrameAllocator::Frame audio_frame, size_t audio_offset, AudioFormat audio_format + ) { + printf("got fraem %d\n", timecode); + UNUSED_PARAMETER(video_format); + UNUSED_PARAMETER(audio_format); + rt->capture->get_video_frame_allocator()->release_frame(video_frame); + rt->capture->get_audio_frame_allocator()->release_frame(audio_frame); + } + ); + rt->capture->configure_card(); + BMUSBCapture::start_bm_thread(); + rt->capture->start_bm_capture(); + + rt->initialized = true; + + UNUSED_PARAMETER(settings); + UNUSED_PARAMETER(source); + return rt; +} + +struct obs_source_info bmusb_source_info = { + .id = "bmusb", + .type = OBS_SOURCE_TYPE_INPUT, + .output_flags = OBS_SOURCE_ASYNC_VIDEO, + .get_name = bmusb_getname, + .create = bmusb_create, + .destroy = bmusb_destroy, +}; + +OBS_DECLARE_MODULE() + +extern "C" bool obs_module_load(void) +{ + obs_register_source(&bmusb_source_info); + return true; +} |
