Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/wrapper_apis/c/jrtc_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <thread>
#include <cassert>
#include <iostream>
#include <memory>
#include "jrtc_app.hpp"

// ###########################################################
Expand Down Expand Up @@ -91,18 +92,19 @@ JrtcApp::Init()

// Create channel if needed
if (s.appChannel) {
si.chan_ctx = jrtc_router_channel_create(
dapp_channel_ctx* raw_ctx = jrtc_router_channel_create(
env_ctx->dapp_ctx,
s.appChannel->is_output,
s.appChannel->num_elems,
s.appChannel->elem_size,
si.sid,
0,
0);
if (si.chan_ctx == NULL) {
if (raw_ctx == NULL) {
std::cout << app_cfg->context << ":: Failure generating channel context for " << s.sid << std::endl;
return -1;
}
si.chan_ctx.reset(raw_ctx);
}

// Register stream if it is for reception
Expand All @@ -115,7 +117,7 @@ JrtcApp::Init()
si.registered = true;
}

stream_items.push_back(si);
stream_items.push_back(std::move(si));

// Check if the initialisation timeout has been exceeded
if (app_cfg->initialization_timeout_secs > 0) {
Expand Down Expand Up @@ -168,9 +170,6 @@ JrtcApp::CleanUp()
if (si.registered) {
jrtc_router_channel_deregister_stream_id_req(env_ctx->dapp_ctx, si.sid);
}
if (si.chan_ctx) {
jrtc_router_channel_destroy(si.chan_ctx);
}
}
}

Expand Down Expand Up @@ -237,7 +236,7 @@ JrtcApp::get_stream(int stream_idx)
dapp_channel_ctx_t
JrtcApp::get_chan_ctx(int stream_idx)
{
return (static_cast<size_t>(stream_idx) < stream_items.size()) ? stream_items[stream_idx].chan_ctx : nullptr;
return (static_cast<size_t>(stream_idx) < stream_items.size()) ? stream_items[stream_idx].chan_ctx.get() : nullptr;
}

// ###########################################################
Expand Down
10 changes: 9 additions & 1 deletion src/wrapper_apis/c/jrtc_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <optional>
#include <functional>
#include <any>
#include <memory>

#include "jrtc_app.h"

Expand All @@ -22,7 +23,14 @@ class JrtcApp
{
jrtc_router_stream_id_t sid; // Stream ID
bool registered; // Registration status of the stream
dapp_channel_ctx_t chan_ctx; // Channel context associated with the stream
std::unique_ptr<dapp_channel_ctx, decltype(&jrtc_router_channel_destroy)>
chan_ctx; // Channel context associated with the stream

StreamItem() : sid(), registered(false), chan_ctx(nullptr, jrtc_router_channel_destroy) {}
StreamItem(jrtc_router_stream_id_t s, bool r, dapp_channel_ctx* c)
: sid(s), registered(r), chan_ctx(c, jrtc_router_channel_destroy)
{
}
};

// Constructor initializing the JrtcApp instance
Expand Down
Loading