Skip to content

Commit

Permalink
add backend_stream_profile::to_stream()
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Oct 8, 2024
1 parent 7d02d8c commit 54c3b1d
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 107 deletions.
4 changes: 2 additions & 2 deletions src/dds/rs-dds-sensor-proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <src/core/roi.h>
#include <src/core/time-service.h>
#include <src/stream.h>
#include <src/context.h>

#include <src/proc/color-formats-converter.h>

Expand Down Expand Up @@ -250,9 +251,8 @@ void dds_sensor_proxy::open( const stream_profiles & profiles )
{
auto & sp = source_profiles[i];
sid_index sidx( sp->get_unique_id(), sp->get_stream_index() );
if( Is< video_stream_profile >( sp ) )
if( auto const vsp = As< video_stream_profile >( sp ) )
{
const auto && vsp = As< video_stream_profile >( source_profiles[i] );
auto video_profile = find_profile(
sidx,
realdds::dds_video_stream_profile( sp->get_framerate(),
Expand Down
3 changes: 2 additions & 1 deletion src/ds/d400/d400-factory.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2016 Intel Corporation. All Rights Reserved.
// Copyright(c) 2016-24 Intel Corporation. All Rights Reserved.

#include <mutex>
#include <chrono>
Expand All @@ -10,6 +10,7 @@
#include "device.h"
#include "image.h"
#include "metadata-parser.h"
#include "context.h"

#include <src/core/matcher-factory.h>

Expand Down
1 change: 1 addition & 0 deletions src/hid-sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "hid-sensor.h"
#include "device.h"
#include "stream.h"
#include "image.h"
#include "global_timestamp_reader.h"
#include "metadata.h"
#include "platform/stream-profile-impl.h"
Expand Down
3 changes: 2 additions & 1 deletion src/media/ros/ros_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.
// Copyright(c) 2019-24 Intel Corporation. All Rights Reserved.

#include "ros_reader.h"
#include "ds/ds-device-common.h"
Expand All @@ -10,6 +10,7 @@
#include <src/core/motion-frame.h>
#include <src/core/video-frame.h>
#include <src/color-sensor.h>
#include <src/context.h>

#include <rsutils/string/from.h>
#include <cstring>
Expand Down
3 changes: 2 additions & 1 deletion src/media/ros/ros_reader.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
// Copyright(c) 2017-24 Intel Corporation. All Rights Reserved.

#pragma once

Expand All @@ -14,6 +14,7 @@ namespace librealsense
{
using namespace device_serializer;

class context;
class frame_source;
class info_container;
class options_interface;
Expand Down
15 changes: 13 additions & 2 deletions src/platform/stream-profile-impl.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2023 Intel Corporation. All Rights Reserved.
// Copyright(c) 2023-4 Intel Corporation. All Rights Reserved.
#pragma once

#include "stream-profile.h"
#include <rsutils/type/fourcc.h>
#include <ostream>


namespace librealsense {
Expand All @@ -23,7 +25,16 @@ class stream_profile_impl : public super
{
}

virtual stream_profile const & get_backend_profile() const override { return _backend_stream_profile; }
stream_profile const & get_backend_profile() const override { return _backend_stream_profile; }

void to_stream( std::ostream & os ) const override
{
os << " [";
os << _backend_stream_profile.width << 'x' << _backend_stream_profile.height;
os << ' ' << rsutils::type::fourcc( _backend_stream_profile.format );
os << " @ " << _backend_stream_profile.fps << " Hz";
os << "]";
}
};


Expand Down
2 changes: 1 addition & 1 deletion src/proc/formats-converter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2023 Intel Corporation. All Rights Reserved.
// Copyright(c) 2023-4 Intel Corporation. All Rights Reserved.

#include "proc/formats-converter.h"
#include "stream.h"
Expand Down
3 changes: 2 additions & 1 deletion src/proc/synthetic-stream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
// Copyright(c) 2017-24 Intel Corporation. All Rights Reserved.

#include "proc/synthetic-stream.h"

Expand All @@ -12,6 +12,7 @@
#include "option.h"
#include "stream.h"
#include "types.h"
#include <src/image.h>
#include <src/core/time-service.h>

#include <rsutils/string/from.h>
Expand Down
5 changes: 3 additions & 2 deletions src/proc/y8i-to-y8y8.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.
// Copyright(c) 2019-24 Intel Corporation. All Rights Reserved.

#include "y8i-to-y8y8.h"

#include "stream.h"
#include <src/stream.h>
#include <src/image.h>

#ifdef RS2_USE_CUDA
#include "cuda/cuda-conversion.cuh"
Expand Down
4 changes: 3 additions & 1 deletion src/sensor.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2015 Intel Corporation. All Rights Reserved.
// Copyright(c) 2015-24 Intel Corporation. All Rights Reserved.

#include "uvc-sensor.h"

#include "source.h"
#include "device.h"
#include "stream.h"
#include "context.h"
#include "image.h"
#include "proc/synthetic-stream.h"
#include "proc/decimation-filter.h"
#include "global_timestamp_reader.h"
Expand Down
196 changes: 111 additions & 85 deletions src/stream.cpp
Original file line number Diff line number Diff line change
@@ -1,111 +1,137 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2015 Intel Corporation. All Rights Reserved.
// Copyright(c) 2015-24 Intel Corporation. All Rights Reserved.

#include "stream.h"
#include <ostream>

namespace librealsense

namespace librealsense {


stream::stream( rs2_stream stream_type, int index )
: _index( index )
, _type( stream_type )
{
stream::stream(rs2_stream stream_type, int index)
: _index(index), _type(stream_type)
{
_uid = environment::get_instance().generate_stream_id();
}
_uid = environment::get_instance().generate_stream_id();
}

int stream::get_stream_index() const
{
return _index;
}
int stream::get_stream_index() const
{
return _index;
}

void stream::set_stream_index(int index)
{
_index = index;
}
void stream::set_stream_index( int index )
{
_index = index;
}

rs2_stream stream::get_stream_type() const
{
return _type;
}
rs2_stream stream::get_stream_type() const
{
return _type;
}

void stream::set_stream_type(rs2_stream stream)
{
_type = stream;
}
void stream::set_stream_type( rs2_stream stream )
{
_type = stream;
}

stream_profile_base::stream_profile_base()
{
_c_ptr = &_c_wrapper;
_c_wrapper.profile = this;
_c_wrapper.clone = nullptr;
}
stream_profile_base::stream_profile_base()
{
_c_ptr = &_c_wrapper;
_c_wrapper.profile = this;
_c_wrapper.clone = nullptr;
}

int stream_profile_base::get_stream_index() const
{
return _index;
}
int stream_profile_base::get_stream_index() const
{
return _index;
}

void stream_profile_base::set_stream_index(int index)
{
_index = index;
}
void stream_profile_base::set_stream_index( int index )
{
_index = index;
}

rs2_stream stream_profile_base::get_stream_type() const
{
return _type;
}
rs2_stream stream_profile_base::get_stream_type() const
{
return _type;
}

void stream_profile_base::set_stream_type(rs2_stream stream)
{
_type = stream;
}
void stream_profile_base::set_stream_type( rs2_stream stream )
{
_type = stream;
}

rs2_format stream_profile_base::get_format() const
{
return _format;
}
rs2_format stream_profile_base::get_format() const
{
return _format;
}

void stream_profile_base::set_format(rs2_format format)
{
_format = format;
}
void stream_profile_base::set_format( rs2_format format )
{
_format = format;
}

uint32_t stream_profile_base::get_framerate() const
{
return _framerate;
}
uint32_t stream_profile_base::get_framerate() const
{
return _framerate;
}

void stream_profile_base::set_framerate(uint32_t val)
{
_framerate = val;
}
void stream_profile_base::set_framerate( uint32_t val )
{
_framerate = val;
}

int stream_profile_base::get_tag() const
{
return _tag;
}
int stream_profile_base::get_tag() const
{
return _tag;
}

void stream_profile_base::tag_profile(int tag)
{
_tag = tag;
}
void stream_profile_base::tag_profile( int tag )
{
_tag = tag;
}

rs2_stream_profile* stream_profile_base::get_c_wrapper() const
{
return _c_ptr;
}

void stream_profile_base::set_c_wrapper(rs2_stream_profile* wrapper)
{
_c_ptr = wrapper;
}
void stream_profile_base::create_snapshot(std::shared_ptr<stream_profile_interface>& snapshot) const
{
auto ptr = std::const_pointer_cast<stream_interface>(shared_from_this());
snapshot = std::dynamic_pointer_cast<stream_profile_interface>(ptr);
}
void stream_profile_base::enable_recording(std::function<void(const stream_profile_interface&)> record_action)
rs2_stream_profile * stream_profile_base::get_c_wrapper() const
{
return _c_ptr;
}


void stream_profile_base::set_c_wrapper( rs2_stream_profile * wrapper )
{
_c_ptr = wrapper;
}


void stream_profile_base::create_snapshot( std::shared_ptr< stream_profile_interface > & snapshot ) const
{
auto ptr = std::const_pointer_cast< stream_interface >( shared_from_this() );
snapshot = std::dynamic_pointer_cast< stream_profile_interface >( ptr );
}


void stream_profile_base::enable_recording( std::function< void( const stream_profile_interface & ) > record_action )
{
// TODO: implement or remove inheritance from recordable<T>
throw not_implemented_exception( __FUNCTION__ );
}


std::ostream & operator<<( std::ostream & os, const stream_profiles & profiles )
{
bool first = true;
for( auto & p : profiles )
{
//TODO: implement or remove inheritance from recordable<T>
throw not_implemented_exception(__FUNCTION__);
if( first )
first = false;
else
os << ", ";
os << p;
}
return os;
}


} // namespace librealsense
Loading

0 comments on commit 54c3b1d

Please sign in to comment.