Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
edbf9cb
Rewrite test app (#284)
zLukas Dec 12, 2024
2cb4d11
[VAL] Initial push for pytest engine (#273)
MateuszGrabuszynski Dec 18, 2024
45b9de4
minor renaming
zLukas Jan 13, 2025
4a0ec7b
cmake improvement
zLukas Jan 13, 2025
aa05a0e
sdk succesfully linked to TestApp
zLukas Jan 13, 2025
afb83d8
minor updates
zLukas Jan 13, 2025
6301310
json api SDK linket to test App
zLukas Jan 14, 2025
69e9ea8
TxApp file serializing implemented
zLukas Jan 14, 2025
b450ec1
minor fixes
zLukas Jan 14, 2025
9832410
receiver side implemented, ready for testing
zLukas Jan 14, 2025
797daf5
add missing step to tx send_video function
zLukas Jan 15, 2025
1e7322b
clear typo
zLukas Jan 15, 2025
d9f5328
txApp can send multiple frames
zLukas Jan 16, 2025
1fdeea6
update rxApp to append the file
zLukas Jan 16, 2025
6cafd57
Merge branch 'main' into zlukas/connect_json_api_to_test_app
zLukas Jan 17, 2025
7e0b5e6
Pair programming session output
MateuszGrabuszynski Jan 17, 2025
6d8af6e
rx app append funct updated
zLukas Jan 17, 2025
1ba9264
Squashed: alignment from Friday and Monday
MateuszGrabuszynski Jan 20, 2025
e931a83
Adding file handling
MateuszGrabuszynski Jan 22, 2025
608a37d
minor cleanup
zLukas Jan 22, 2025
c0cc3d4
check for root access
zLukas Jan 22, 2025
bf6778a
debug data transfer succesfull
MateuszGrabuszynski Jan 22, 2025
0d01ad6
simplify send video function, update file writing in RX app
MateuszGrabuszynski Jan 23, 2025
f03178e
dev test cleanup, rxApp logic moved to mcm.c file
zLukas Jan 23, 2025
95ec25a
add logging info
zLukas Jan 23, 2025
1c26a50
remove unnecessary function cals
zLukas Jan 23, 2025
8986ca3
Merge branch 'main' into zlukas/connect_json_api_to_test_app
zLukas Jan 23, 2025
e7faf58
run clang-format on code files
zLukas Jan 23, 2025
e62981a
fix: typo succesfully -> successfully
MateuszGrabuszynski Jan 23, 2025
f758736
Changing usage message for path to file
MateuszGrabuszynski Jan 23, 2025
d31b258
Exiting instead of returns; avoiding segfault by exiting more
MateuszGrabuszynski Jan 23, 2025
655c3c9
Adding a space before BSD_LIB variable
MateuszGrabuszynski Jan 23, 2025
27bd182
Switched all printf() messages to include [RX]/[TX] at the beginning …
MateuszGrabuszynski Jan 23, 2025
baf1f78
Removed 2 includes of mcm_dp.h
MateuszGrabuszynski Jan 23, 2025
3379d28
Removing unnecessary comments
MateuszGrabuszynski Jan 23, 2025
bdf6c26
Changing mcm_send_video_frame to mcm_send_video_frames, frame_file to…
MateuszGrabuszynski Jan 23, 2025
e780922
Adding missing exit()
MateuszGrabuszynski Jan 23, 2025
4ea8a4e
Adding a todo message for pacing implementation
MateuszGrabuszynski Jan 23, 2025
210f4ae
remove unneccessery files
zLukas Jan 23, 2025
f4227c4
run-clang formatter
zLukas Jan 23, 2025
151287e
linter fix
zLukas Jan 23, 2025
e1d9658
exclude C test app from CPP lint
zLukas Jan 23, 2025
a9672f5
update cpplint.cfg
zLukas Jan 23, 2025
40c9cd5
update cpplint.cfg
zLukas Jan 23, 2025
1a059ea
run clang-format once again
zLukas Jan 23, 2025
1693313
Merge branch 'main' into zlukas/connect_json_api_to_test_app
MateuszGrabuszynski Jan 24, 2025
03a4526
docs: Improving README's structure, adding json examples for client a…
MateuszGrabuszynski Jan 24, 2025
218cbed
fix header guards in header files
zLukas Jan 27, 2025
f62d499
fix comment style
zLukas Jan 27, 2025
af2ab53
minor refactor
zLukas Jan 27, 2025
04b75d1
minor refactor
zLukas Jan 27, 2025
3f91324
proper functions exit, deallocating memory in main files
zLukas Jan 27, 2025
9b30343
add goto statement, update syntax
zLukas Jan 27, 2025
352fe40
readme update
zLukas Jan 27, 2025
901eb0c
Update input.h
zLukas Jan 27, 2025
2d40dac
Update client_example.json
zLukas Jan 27, 2025
637c9a1
Update mcm.h
zLukas Jan 27, 2025
39e394f
Update connection_example.json
zLukas Jan 27, 2025
18d7223
run clang format
zLukas Jan 27, 2025
e72c8b9
Merge remote-tracking branch 'upstream/main' into zlukas/connect_json…
zLukas Jan 27, 2025
8859c6c
remove const from json parsing return type, remove casting in derefer…
zLukas Jan 27, 2025
423aa2c
simplify is_root function, add break; to all errors in receive loop
zLukas Jan 27, 2025
4ef5b2a
minor refactor
zLukas Jan 27, 2025
0c772a1
removed unecessary returns
zLukas Jan 27, 2025
9422588
update license info
zLukas Jan 27, 2025
6f74540
style changes
zLukas Jan 27, 2025
ba13e5f
run clang-format
zLukas Jan 27, 2025
c0926f5
Merge branch 'main' into zlukas/connect_json_api_to_test_app
zLukas Jan 27, 2025
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
2 changes: 2 additions & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set noparent
exclude_files=tests
24 changes: 21 additions & 3 deletions tests/tools/TestApp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@ cmake_minimum_required(VERSION 3.10)

# Set the project name and version
project(TestApps VERSION 1.0)
# Include directories
include_directories(Inc)

set(SRC src/input.c src/mcm.c src/mcm_mock.c)
# Find the threading library
find_package(Threads REQUIRED)

# Find the BSD library
find_library(BSD_LIB bsd REQUIRED)

execute_process(
COMMAND git rev-parse --show-toplevel
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REPO_ROOT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "************* root project dir: ${GIT_REPO_ROOT} *************")

set(INC ${GIT_REPO_ROOT}/sdk/include Inc)
set(SRC src/input.c src/mcm.c)

include_directories(${INC})

# Add the executable
add_executable(TxApp tx_app.c ${SRC})
add_executable(RxApp rx_app.c ${SRC})


target_link_libraries(TxApp PRIVATE memif ${CMAKE_THREAD_LIBS_INIT} ${BSD_LIB} mcm_dp)
target_link_libraries(RxApp PRIVATE memif ${CMAKE_THREAD_LIBS_INIT} ${BSD_LIB} mcm_dp)

12 changes: 8 additions & 4 deletions tests/tools/TestApp/Inc/input.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 Intel Corporation
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#ifndef _INPUT_H_
#define _INPUT_H_

const char* parse_json_to_string(const char* file_name);
int is_mock_enabled();

char *parse_json_to_string(const char *file_name);

#endif /* _INPUT_H_*/
#endif /* _INPUT_H_ */
30 changes: 16 additions & 14 deletions tests/tools/TestApp/Inc/mcm.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@

/*
* SPDX-FileCopyrightText: Copyright (c) 2025 Intel Corporation
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#ifndef _MCM_H_
#define _MCM_H_
#include "mcm_mock.h"

#define DUMMY_LEN 1
typedef struct mcm_ts{
MeshConnection *connection;
MeshClient *client;
}mcm_ts;

#include <stdio.h>
#include "mesh_dp.h"

int mcm_init_client(mcm_ts* mcm, const char* cfg);
int mcm_create_tx_connection(mcm_ts* mcm, const char* cfg);
int mcm_create_rx_connection(mcm_ts* mcm, const char* cfg);
int mcm_send_video_frame(mcm_ts* mcm, const char* frame, int frame_len);
int mcm_receive_video_frames(mcm_ts* mcm);
int file_to_buffer(FILE* fp, MeshBuffer* buf, int frame_size);
int mcm_init_client(MeshConnection **connection, MeshClient *client, const char *cfg);
int mcm_create_tx_connection(MeshConnection *connection, MeshClient *client, const char *cfg);
int mcm_create_rx_connection(MeshConnection *connection, MeshClient *client, const char *cfg);
int mcm_send_video_frames(MeshConnection *connection, const char *filename);
void read_data_in_loop(MeshConnection *connection, const char *filename);
int is_root();

#endif /* _MCM_H_*/
#endif /* _MCM_H_ */
35 changes: 0 additions & 35 deletions tests/tools/TestApp/Inc/mcm_mock.h

This file was deleted.

64 changes: 37 additions & 27 deletions tests/tools/TestApp/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
# TestApp

Application for utilizing MCM api,
Application for utilizing Media Communications Mesh SDK API.

*Disclaimer*
TX/RXapp is prepared for new api (/docs/sdk-json-proposal) that is not implemented yet, so, so far it works with simple mocks, that move a file from TxApp to RxApp.
## Prerequisities
before building this code following libreries need to be build and installed on host system:
* [grpc](grpcMedia-Communications-Mesh/sdk/README.md)
* [memif](Media-Communications-Mesh/sdk/3rdparty/libmemif/docs/buildinstructions_doc.rst)

test apps use them as shared libraries during linking stage, without them, compilation will fail.

## Usage
1. Create directory:
```shell
mkdir /tmp/MCM_MOCK
```
1. Build binaries:
```shell
mkdir build && cd build
cmake ..
make
touch client.json
touch connection.json
```
```shell
mkdir build && cd build
cmake ..
make
```

1. Run RxApp:
```shell
$ ./RxApp
launching RX App
RX App PID: 956656
reading client configuration...
reading connection configuration...
waiting for frames..
2. Prepare client and conneciton files for sender (TxApp) and receiver (RxApp)
```shell
touch client_tx.json
touch connection_tx.json
touch client_rx.json
touch connection_rx.json
```
> Note: The names of the files can differ from the ones presented above, but they must be reflected in the commands as in the following points.
Exemplary contents of those files can be found in [`client_example.json`](client_example.json) and [`connection_example.json`](connection_example.json). For more, check [appropriate documentation](../../../docs/sdk-json-proposal/SDK_API_WORKFLOW.md).

```
3. Run RxApp:
```shell
./RxApp <client_cfg.json> <connection_cfg.json> <path_to_output_file>
```
For example:
```shell
./RxApp client_rx.json connection_rx.json output_video.yuv
```

1. Run TxApp:
```shell
./TxApp <abs path to file to transmit> <RX App PID>
```
4. Run TxApp:
```shell
./TxApp <client_cfg.json> <connection_cfg.json> <path_to_input_file>
```
For example:
```shell
./RxApp client_tx.json connection_tx.json input_video.yuv
```
6 changes: 6 additions & 0 deletions tests/tools/TestApp/client_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"apiVersion": "v1",
"apiConnectionString": "Server=127.0.0.1; Port=8002",
"apiDefaultTimeoutMicroseconds": 100000,
"maxMediaConnections": 32
}
15 changes: 15 additions & 0 deletions tests/tools/TestApp/connection_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"connection": {
"multipointGroup": {
"urn": "ipv4:192.168.123.123"
}
},
"payload": {
"video": {
"width": 1920,
"height": 1080,
"fps": 60.0,
"pixelFormat": "yuv422p10rfc4175"
}
}
}
77 changes: 55 additions & 22 deletions tests/tools/TestApp/rx_app.c
Original file line number Diff line number Diff line change
@@ -1,26 +1,59 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "Inc/input.h"
#include "Inc/mcm.h"
#include <unistd.h>

const char* client_cfg;
const char* conn_cfg;

int main(int argc, char* argv[]){

printf("launching RX App \n");
printf("RX App PID: %d\n", getpid());
printf("reading client configuration... \n");
client_cfg = parse_json_to_string("client.json");
printf("reading connection configuration... \n");
conn_cfg = parse_json_to_string("connection.json");
mcm_ts mcm;
mcm_init_client(&mcm, client_cfg);
mcm_create_rx_connection(&mcm, conn_cfg);
printf("waiting for frames... \n");
while(1){
// mcm_create_rx_connection(&mcm, conn_cfg);
// mcm_receive_video_frames(&mcm);
}
return 0;
}
char *client_cfg;
char *conn_cfg;

int main(int argc, char *argv[]) {
if (!is_root()) {
fprintf(stderr, "This program must be run as root. Exiting.\n");
exit(EXIT_FAILURE);
}
if (argc != 4) {
fprintf(stderr, "Usage: %s <client_cfg.json> <connection_cfg.json> <path_to_output_file>\n",
argv[0]);
exit(EXIT_FAILURE);
}

char *client_cfg_file = argv[1];
char *conn_cfg_file = argv[2];
char *out_filename = argv[3];

MeshConnection *connection = NULL;
MeshClient *client = NULL;

printf("[RX] Launching RX App \n");
printf("[RX] Reading client configuration... \n");
client_cfg = parse_json_to_string(client_cfg_file);
printf("[RX] Reading connection configuration... \n");
conn_cfg = parse_json_to_string(conn_cfg_file);

/* Initialize mcm client */
int err = mesh_create_client_json(&client, client_cfg);
if (err) {
printf("[RX] Failed to create mesh client: %s (%d)\n", mesh_err2str(err), err);
goto safe_exit;
}

/* Create mesh connection */
err = mesh_create_rx_connection(client, &connection, conn_cfg);
if (err) {
printf("[RX] Failed to create connection: %s (%d)\n", mesh_err2str(err), err);
mesh_delete_client(&client);
goto safe_exit;
}
printf("[RX] Waiting for frames... \n");
read_data_in_loop(connection, out_filename);
printf("[RX] Shuting down connection and client\n");
mesh_delete_connection(&connection);
mesh_delete_client(&client);
printf("[RX] Shutdown completed exiting\n");

safe_exit:
free(client_cfg);
free(conn_cfg);
return err;
}
17 changes: 8 additions & 9 deletions tests/tools/TestApp/src/input.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#include "input.h"
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 Intel Corporation
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include "input.h"


const char* parse_json_to_string(const char* file_name) {
char *parse_json_to_string(const char *file_name) {
FILE *input_fp = fopen(file_name, "rb");
if (input_fp == NULL) {
perror("Failed to open a file");
Expand All @@ -19,7 +23,7 @@ const char* parse_json_to_string(const char* file_name) {
fseek(input_fp, 0, SEEK_SET); // Rewind to the beginning of the file

// Allocate memory to hold the file contents plus a null terminator
char *buffer = (char*)malloc(file_size + 1);
char *buffer = (char *)malloc(file_size + 1);
if (buffer == NULL) {
perror("Failed to allocate memory");
fclose(input_fp);
Expand All @@ -44,8 +48,3 @@ const char* parse_json_to_string(const char* file_name) {
// Return the buffer as a const char*
return buffer;
}

int is_mock_enabled(int argc, char *argv[]){
return (argc == 2 && strcmp("mock", argv[1]) == 0) ? 1 : 0;
}

Loading