[0.0.6] add media transporter param
[platform/core/api/mediatransporter.git] / test / mtpr_rtsp_test.c
1 /*
2 * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <gst/gst.h>
18 #include <gst/rtsp-server/rtsp-server.h>
19
20 #ifdef PACKAGE
21 #undef PACKAGE
22 #endif
23 #define PACKAGE "mtpr_rtsp_test"
24
25 #ifdef LOG_TAG
26 #undef LOG_TAG
27 #endif
28 #define LOG_TAG "MTPR_TEST"
29
30 #define DEFAULT_RTSP_PORT "8554"
31
32 int main(int argc, char *argv[])
33 {
34         GMainLoop *loop;
35         GstRTSPServer *server;
36         GstRTSPMountPoints *mounts;
37         GstRTSPMediaFactory *factory;
38
39         if (argc < 2) {
40                 g_print("Enter launch cmd : \"( decodebin name=depay0 ! videoconvert ! tizenwlsink )\"\n");
41                 return 1;
42         }
43
44         gst_init(NULL, NULL);
45         loop = g_main_loop_new(NULL, FALSE);
46
47         server = gst_rtsp_server_new();
48         g_object_set(server, "service", DEFAULT_RTSP_PORT, NULL);
49
50         mounts = gst_rtsp_server_get_mount_points(server);
51
52         factory = gst_rtsp_media_factory_new();
53         gst_rtsp_media_factory_set_transport_mode(factory, GST_RTSP_TRANSPORT_MODE_RECORD);
54         gst_rtsp_media_factory_set_launch(factory, argv[1]);
55
56         gst_rtsp_mount_points_add_factory(mounts, "/test", factory);
57         g_object_unref(mounts);
58
59         gst_rtsp_server_attach(server, NULL);
60
61         g_print("stream ready at rtsp://127.0.0.1:%s/test\n", DEFAULT_RTSP_PORT);
62         g_main_loop_run(loop);
63
64         return 0;
65 }