Changeset 518 for pjproject/trunk/pjmedia/src/pjmedia/port.c
- Timestamp:
- Jun 18, 2006 2:02:36 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/port.c
r358 r518 26 26 27 27 /** 28 * Connect two ports.29 */30 PJ_DEF(pj_status_t) pjmedia_port_connect( pj_pool_t *pool,31 pjmedia_port *upstream_port,32 pjmedia_port *downstream_port)33 {34 pj_status_t status;35 36 PJ_ASSERT_RETURN(pool && upstream_port && downstream_port, PJ_EINVAL);37 38 #if 039 /* They both MUST have the same media type. */40 PJ_ASSERT_RETURN(upstream_port->info.type ==41 downstream_port->info.type, PJMEDIA_ENCTYPE);42 43 /* They both MUST have the same clock rate. */44 PJ_ASSERT_RETURN(upstream_port->info.sample_rate ==45 downstream_port->info.sample_rate, PJMEDIA_ENCCLOCKRATE);46 47 /* They both MUST have the same samples per frame */48 PJ_ASSERT_RETURN(upstream_port->info.samples_per_frame ==49 downstream_port->info.samples_per_frame,50 PJMEDIA_ENCSAMPLESPFRAME);51 52 /* They both MUST have the same bits per sample */53 PJ_ASSERT_RETURN(upstream_port->info.bits_per_sample ==54 downstream_port->info.bits_per_sample,55 PJMEDIA_ENCBITS);56 57 /* They both MUST have the same bytes per frame */58 PJ_ASSERT_RETURN(upstream_port->info.bytes_per_frame ==59 downstream_port->info.bytes_per_frame,60 PJMEDIA_ENCBYTES);61 #endif62 63 /* Create mutual attachment. */64 if (upstream_port->on_downstream_connect) {65 status = upstream_port->on_downstream_connect( pool, upstream_port,66 downstream_port );67 if (status != PJ_SUCCESS)68 return status;69 }70 71 if (downstream_port->on_upstream_connect) {72 status = downstream_port->on_upstream_connect( pool, downstream_port,73 upstream_port );74 if (status != PJ_SUCCESS)75 return status;76 }77 78 /* Save the attachment. */79 upstream_port->downstream_port = downstream_port;80 downstream_port->upstream_port = upstream_port;81 82 /* Done. */83 return PJ_SUCCESS;84 }85 86 87 /**88 * Disconnect ports.89 */90 PJ_DEF(pj_status_t) pjmedia_port_disconnect( pjmedia_port *upstream_port,91 pjmedia_port *downstream_port)92 {93 PJ_ASSERT_RETURN(upstream_port && downstream_port, PJ_EINVAL);94 95 if (upstream_port->downstream_port == downstream_port)96 upstream_port->downstream_port = NULL;97 98 if (downstream_port->upstream_port == upstream_port)99 downstream_port->upstream_port = NULL;100 101 return PJ_SUCCESS;102 }103 104 105 /**106 28 * Get a frame from the port (and subsequent downstream ports). 107 29 */ … … 114 36 return port->get_frame(port, frame); 115 37 } 116 117 38 118 39 … … 140 61 PJ_ASSERT_RETURN(port, PJ_EINVAL); 141 62 142 /* Recursively call this function again to destroy downstream143 * port first.144 */145 if (port->downstream_port) {146 status = pjmedia_port_destroy(port->downstream_port);147 if (status != PJ_SUCCESS)148 return status;149 pjmedia_port_disconnect(port, port->downstream_port);150 }151 152 63 if (port->on_destroy) 153 64 status = port->on_destroy(port); … … 160 71 161 72 162
Note: See TracChangeset
for help on using the changeset viewer.