|
| 1 | +```mermaid |
| 2 | +sequenceDiagram |
| 3 | + participant App as Application |
| 4 | + participant Session as Media Library Session |
| 5 | +
|
| 6 | + participant Network as Network I/O |
| 7 | +
|
| 8 | + Note over App,Network: Library-Owned Receiver Flow (sample-rx-lib-owned.c) |
| 9 | + |
| 10 | + App->>Session: media_lib_video_session_create(instance, &rx_config, &session) |
| 11 | + Session->>Session: Allocate memory (for NUM_BUFFERS) |
| 12 | + Session->>Network: Setup receiver |
| 13 | + Session->>Network: Add buffers to receive queue |
| 14 | + Session-->>App: Return session handle |
| 15 | + |
| 16 | + loop Receive and process loop |
| 17 | + App->>Session: media_lib_buffer_get(session, &buffer, TIMEOUT_MS) |
| 18 | + Session->>Network: Wait for data |
| 19 | + Network-->>Session: Data received |
| 20 | +
|
| 21 | + Session-->>App: Return buffer pointer |
| 22 | + |
| 23 | + Note over App: Process buffer data |
| 24 | + |
| 25 | + App->>Session: media_lib_buffer_put(session, buffer) |
| 26 | +
|
| 27 | + Session->>Network: Add buffer to receive queue |
| 28 | + Session-->>App: MEDIA_LIB_SUCCESS |
| 29 | +
|
| 30 | + end |
| 31 | + App->>Session: media_lib_session_shutdown(session) |
| 32 | +
|
| 33 | + App->>Session: media_lib_session_destroy(session) |
| 34 | + Session->>Session: Deallocate memory |
| 35 | +
|
| 36 | +``` |
| 37 | + |
| 38 | +```mermaid |
| 39 | +sequenceDiagram |
| 40 | + participant App as Application |
| 41 | + participant Session as Media Library Session |
| 42 | + participant Network as Network I/O |
| 43 | + |
| 44 | + Note over App,Network: Library-Owned Transmitter Flow (sample-tx-lib-owned.c) |
| 45 | + |
| 46 | + App->>Session: media_lib_video_session_create(instance, &tx_config, &session) |
| 47 | + Session->>Session: Allocate memory (for NUM_BUFFERS) |
| 48 | + Session->>Network: Setup transmitter |
| 49 | + Session-->>App: Return session handle |
| 50 | + |
| 51 | + |
| 52 | + loop Acquire, fill, and transmit loop |
| 53 | + App->>Session: media_lib_buffer_get(session, &buffer, TIMEOUT_MS) |
| 54 | + Session->>Session: Wait for available buffer |
| 55 | + Session-->>App: Return available buffer |
| 56 | + |
| 57 | + Note over App: Fill buffer with media data |
| 58 | + |
| 59 | + App->>Session: media_lib_buffer_put(session, buffer) |
| 60 | + Session->>Network: Start transmission |
| 61 | + Session-->>App: MEDIA_LIB_SUCCESS |
| 62 | + Network-->>Session: Transmission complete |
| 63 | + Session->>Session: Mark buffer as available |
| 64 | +
|
| 65 | + end |
| 66 | +
|
| 67 | + App->>Session:media_lib_buffers_flush(session) |
| 68 | + App->>Session: media_lib_session_shutdown(session) |
| 69 | + App->>Session: media_lib_session_destroy(session) |
| 70 | + Session->>Session: Deallocate memory |
| 71 | +
|
| 72 | +``` |
| 73 | + |
| 74 | +```mermaid |
| 75 | +sequenceDiagram |
| 76 | + participant App as Application |
| 77 | + participant Session as Media Library Session |
| 78 | + participant DMA as DMA Memory Manager |
| 79 | + participant Events as Event Queue |
| 80 | + participant Network as Network I/O |
| 81 | + |
| 82 | + Note over App,Events: App-Owned Receiver Flow (sample-rx-app-owned.c) |
| 83 | + |
| 84 | + App->>Session: media_lib_video_session_create(instance, &rx_config, &session) |
| 85 | + Session->>Network: Setup receiver |
| 86 | + Session-->>App: Return session handle |
| 87 | + |
| 88 | + App->>App: Allocate memory (for NUM_BUFFERS) |
| 89 | + App->>Session: media_lib_mem_register(session, memory, size, &dma_mem) |
| 90 | + Session->>DMA: Register memory for DMA |
| 91 | + DMA-->>Session: DMA handle |
| 92 | + Session-->>App: Return DMA handle |
| 93 | + |
| 94 | + loop Buffer setup loop |
| 95 | + App->>App: Create app_buffer_t for each buffer segment |
| 96 | + App->>Session: media_lib_buffer_post(session, data, size, app_buffer) |
| 97 | + Session->>Network: Add buffer to receive queue |
| 98 | + end |
| 99 | + |
| 100 | + loop Poll and process loop |
| 101 | + App->>Session: media_lib_event_poll(session, &event, TIMEOUT_MS) |
| 102 | + Session->>Events: Check for events |
| 103 | + |
| 104 | + alt Data received |
| 105 | + Network->>Session: Data received in posted buffer |
| 106 | + Session->>Events: Add BUFFER_RECEIVED event |
| 107 | + Events-->>Session: Return event |
| 108 | + Session-->>App: Return event with app_buffer context |
| 109 | + |
| 110 | + Note over App: Process buffer data |
| 111 | + |
| 112 | + App->>Session: media_lib_buffer_post(session, buf->data, buf->size, buf) |
| 113 | + Session->>Network: Repost buffer for next receive |
| 114 | + end |
| 115 | + end |
| 116 | + |
| 117 | + Note over App: Cleanup (not shown in sample) |
| 118 | + App->>Session: media_lib_mem_unregister(session, dma_mem) |
| 119 | + App->>Session: media_lib_session_shutdown(session) |
| 120 | + App->>Session: media_lib_session_destroy(session) |
| 121 | +
|
| 122 | +``` |
| 123 | + |
| 124 | +```mermaid |
| 125 | +sequenceDiagram |
| 126 | + participant ProducerThread as Producer Thread |
| 127 | + participant PollerThread as Poller Thread |
| 128 | + participant BufferQueue as Buffer Queue |
| 129 | + participant Session as Media Library Session |
| 130 | + participant DMA as DMA Memory Manager |
| 131 | + participant Events as Event Queue |
| 132 | + participant Network as Network I/O |
| 133 | + |
| 134 | + Note over ProducerThread,Events: App-Owned Transmitter Flow (sample-tx-app-owned.c) |
| 135 | + |
| 136 | + Note over ProducerThread,PollerThread: Main thread setup (not shown) |
| 137 | + |
| 138 | + Note over Session,DMA: Memory registration occurs in main thread |
| 139 | + |
| 140 | + loop Producer Thread Loop |
| 141 | + ProducerThread->>BufferQueue: dequeue() - Get free buffer |
| 142 | + BufferQueue-->>ProducerThread: Return app_buffer_t |
| 143 | + Note over ProducerThread: Fill buffer with data |
| 144 | + ProducerThread->>Session: media_lib_buffer_post(session, buf->data, buf->size, buf) |
| 145 | + Session->>Network: Queue buffer for transmission |
| 146 | + end |
| 147 | + |
| 148 | + loop Poller Thread Loop |
| 149 | + PollerThread->>Session: media_lib_event_poll(session, &event, TIMEOUT_MS) |
| 150 | + Session->>Events: Check for events |
| 151 | + alt Transmission complete |
| 152 | + Events-->>Session: Return BUFFER_TRANSMITTED event |
| 153 | + Session-->>PollerThread: Return event with app_buffer context |
| 154 | + PollerThread->>BufferQueue: enqueue(buffer) - Return to free queue |
| 155 | + end |
| 156 | + end |
| 157 | + |
| 158 | + Note over ProducerThread,PollerThread: Cleanup (not reached in sample) |
| 159 | +
|
| 160 | +``` |
0 commit comments