1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 /**************************************************************************/
12 /**************************************************************************/
13 /**                                                                       */
14 /** USBX Component                                                        */
15 /**                                                                       */
16 /**   Device Video Class                                                  */
17 /**                                                                       */
18 /**************************************************************************/
19 /**************************************************************************/
20 
21 #define UX_SOURCE_CODE
22 
23 
24 /* Include necessary system files.  */
25 
26 #include "ux_api.h"
27 #include "ux_device_class_video.h"
28 #include "ux_device_stack.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _ux_device_class_video_stream_get                   PORTABLE C      */
36 /*                                                           6.1.11       */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Chaoqiong Xiao, Microsoft Corporation                               */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function get the stream instance of Video class.               */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    video                                 Address of video class        */
48 /*                                            instance                    */
49 /*    stream_index                          Stream instance index 0 based */
50 /*    stream                                Pointer to buffer to fill     */
51 /*                                            pointer to stream instance  */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    Completion Status                                                   */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    _ux_utility_thread_delete             Delete thread used            */
60 /*    _ux_utility_memory_free               Free used local memory        */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    Video Class                                                         */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  04-25-2022     Chaoqiong Xiao           Initial Version 6.1.11        */
71 /*                                                                        */
72 /**************************************************************************/
_ux_device_class_video_stream_get(UX_DEVICE_CLASS_VIDEO * video,ULONG stream_index,UX_DEVICE_CLASS_VIDEO_STREAM ** stream)73 UINT    _ux_device_class_video_stream_get(UX_DEVICE_CLASS_VIDEO *video,
74         ULONG stream_index, UX_DEVICE_CLASS_VIDEO_STREAM **stream)
75 {
76 
77 
78     /* Sanity check.  */
79     if (video == UX_NULL)
80         return(UX_ERROR);
81 
82     /* Index validation.  */
83     if (stream_index >= video -> ux_device_class_video_streams_nb)
84         return(UX_ERROR);
85 
86     /* Store the stream instance found.  */
87     if (stream)
88         *stream = video -> ux_device_class_video_streams + stream_index;
89 
90     /* Return completion status.  */
91     return(UX_SUCCESS);
92 }
93