|
| 1 | +/** |
| 2 | + * @file omt_common.cpp |
| 3 | + * @author Martin Piatka <piatka@cesnet.cz> |
| 4 | + */ |
| 5 | +/* |
| 6 | + * Copyright (c) 2026 CESNET, zájmové sdružení právických osob |
| 7 | + * All rights reserved. |
| 8 | + * |
| 9 | + * Redistribution and use in source and binary forms, with or without |
| 10 | + * modification, is permitted provided that the following conditions |
| 11 | + * are met: |
| 12 | + * |
| 13 | + * 1. Redistributions of source code must retain the above copyright |
| 14 | + * notice, this list of conditions and the following disclaimer. |
| 15 | + * |
| 16 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | + * notice, this list of conditions and the following disclaimer in the |
| 18 | + * documentation and/or other materials provided with the distribution. |
| 19 | + * |
| 20 | + * 3. Neither the name of CESNET nor the names of its contributors may be |
| 21 | + * used to endorse or promote products derived from this software without |
| 22 | + * specific prior written permission. |
| 23 | + * |
| 24 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS |
| 25 | + * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, |
| 26 | + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
| 27 | + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 28 | + * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 29 | + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 30 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 31 | + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 32 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 33 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 34 | + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
| 35 | + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 36 | + */ |
| 37 | + |
| 38 | +#include "omt_common.hpp" |
| 39 | + |
| 40 | +#include <cassert> |
| 41 | +#include <config.h> //for VERSION |
| 42 | + |
| 43 | +#include "debug.h" |
| 44 | +#include "types.h" |
| 45 | +#include "video_codec.h" |
| 46 | +#define MOD_NAME "[omt] " |
| 47 | + |
| 48 | +void omt_log_callback(const char *msg){ |
| 49 | + log_msg(LOG_LEVEL_INFO, MOD_NAME "[libomt] %s\n", msg); |
| 50 | +} |
| 51 | + |
| 52 | +void set_omt_sender_info(omt_send_t *send_handle){ |
| 53 | + OMTSenderInfo info = {}; |
| 54 | + std::string productName = "UltraGrid"; |
| 55 | + std::string manufacturer = "CESNET"; |
| 56 | + std::string version = VERSION; |
| 57 | + productName.copy(info.ProductName, OMT_MAX_STRING_LENGTH, 0); |
| 58 | + manufacturer.copy(info.Manufacturer, OMT_MAX_STRING_LENGTH, 0); |
| 59 | + version.copy(info.Version, OMT_MAX_STRING_LENGTH, 0); |
| 60 | + omt_send_setsenderinformation(send_handle, &info); |
| 61 | +} |
| 62 | + |
| 63 | +bool omt_frame_init_from_desc(OMTMediaFrame& f, const video_desc& frame_desc){ |
| 64 | + f.Width = frame_desc.width; |
| 65 | + f.Height = frame_desc.height; |
| 66 | + if(frame_desc.color_spec != UYVY){ |
| 67 | + log_msg(LOG_LEVEL_FATAL, MOD_NAME "Codec %s not supported\n", get_codec_name(frame_desc.color_spec)); |
| 68 | + return false; |
| 69 | + } |
| 70 | + f.Codec = OMTCodec_UYVY; |
| 71 | + f.ColorSpace = OMTColorSpace_BT709; |
| 72 | + f.FrameRateN = frame_desc.fps * 1000.0; |
| 73 | + f.FrameRateD = 1000; |
| 74 | + return true; |
| 75 | +} |
| 76 | + |
| 77 | +void omt_frame_set_data(OMTMediaFrame& f, const video_frame& ug_frame){ |
| 78 | + assert(ug_frame.tile_count == 1); |
| 79 | + f.Stride = vc_get_linesize(ug_frame.tiles[0].width, ug_frame.color_spec); |
| 80 | + f.Data = ug_frame.tiles[0].data; |
| 81 | + f.DataLength = ug_frame.tiles[0].data_len; |
| 82 | +} |
| 83 | + |
0 commit comments