Changeset 353 for pjproject/trunk
- Timestamp:
- Mar 23, 2006 2:20:42 PM (19 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/build/os-darwinos.mak
r341 r353 8 8 # to all operating systems should go in Makefile instead. 9 9 # 10 export PJMEDIA_OBJS += $(PA_DIR)/pa_mac_core.o $(PA_DIR)/pa_mac_hostapis.o \ 11 $(PA_DIR)/pa_unix_util.o 10 export PJMEDIA_OBJS += $(PA_DIR)/pa_mac_hostapis.o \ 11 $(PA_DIR)/pa_unix_util.o \ 12 $(PA_DIR)/pa_mac_core.o 13 14 # $(PA_DIR)/pa_mac_alt.o 12 15 # $(PA_DIR)/ringbuffer.o 13 16 -
pjproject/trunk/pjsip-apps/src/samples/sndinfo.c
r350 r353 25 25 " \n" 26 26 " USAGE: \n" 27 " sndinfo [id r /p clockrate nchan bits]\n"27 " sndinfo [id rec/play/both clockrate nchan bits] \n" 28 28 " \n" 29 29 " DESCRIPTION: \n" … … 33 33 " When invoked with arguments, the program tests if device can be opened \n" 34 34 " with the specified arguments. All these arguments must be specified: \n" 35 " - id The device ID (-1 for the first capable device) \n"36 " - r /p Specify r for recording/capture, p for playing.\n"37 " - clockrate Specify clock rate (e.g. 8000, 11025, etc.)\n"38 " - nchan Number of channels (1=mono, 2=stereo).\n"39 " - bits 35 " - id The device ID (-1 for the first capable device) \n" 36 " - rec/play/both Specify which streams to open. \n" 37 " - clockrate Specify clock rate (e.g. 8000, 11025, etc.) \n" 38 " - nchan Number of channels (1=mono, 2=stereo). \n" 39 " - bits Number of bits per sample (normally 16). \n"; 40 40 41 41 #include <pjmedia.h> … … 70 70 info->default_samples_per_sec); 71 71 } 72 } 73 72 puts(""); 73 puts("Run with -h to get more options"); 74 } 75 76 static int play_counter; 77 static int rec_counter; 74 78 75 79 static pj_status_t play_cb(void *user_data, pj_uint32_t timestamp, 76 80 void *output, unsigned size) 77 81 { 82 ++play_counter; 78 83 return PJ_SUCCESS; 79 84 } … … 82 87 const void *input, unsigned size) 83 88 { 89 ++rec_counter; 84 90 return PJ_SUCCESS; 85 91 } 86 92 87 static int open_device(int dev_id, int capturing, int clock_rate, 88 int nchannel, int bits) 89 { 90 pj_status_t status; 93 static void app_perror(const char *title, pj_status_t status) 94 { 95 char errmsg[PJ_ERR_MSG_SIZE]; 96 97 pj_strerror(status, errmsg, sizeof(errmsg)); 98 printf( "%s: %s (err=%d)\n", 99 title, errmsg, status); 100 } 101 102 static int open_device(int dev_id, pjmedia_dir dir, 103 int clock_rate, int nchannel, int bits) 104 { 105 pj_status_t status = PJ_SUCCESS; 91 106 unsigned nsamples; 92 107 pjmedia_snd_stream *strm; 93 108 const char *dirtype; 109 110 switch (dir) { 111 case PJMEDIA_DIR_CAPTURE: 112 dirtype = "capture"; break; 113 case PJMEDIA_DIR_PLAYBACK: 114 dirtype = "playback"; break; 115 case PJMEDIA_DIR_CAPTURE_PLAYBACK: 116 dirtype = "capture/playback"; break; 117 default: 118 return 1; 119 } 120 94 121 nsamples = clock_rate * 20 / 1000; 95 122 96 printf( "Opening device %d : clockrate=%d, nchannel=%d, bits=%d, "97 " nsamples=%d..\n",98 dev_id, clock_rate, nchannel, bits, nsamples);99 100 if ( capturing) {101 status = pjmedia_snd_open_rec order( dev_id, clock_rate, nchannel,102 103 104 } else {123 printf( "Opening device %d for %s: clockrate=%d, nchannel=%d, " 124 "bits=%d, nsamples=%d..\n", 125 dev_id, dirtype, clock_rate, nchannel, bits, nsamples); 126 127 if (dir == PJMEDIA_DIR_CAPTURE) { 128 status = pjmedia_snd_open_rec( dev_id, clock_rate, nchannel, 129 nsamples, bits, &rec_cb, NULL, 130 &strm); 131 } else if (dir == PJMEDIA_DIR_PLAYBACK) { 105 132 status = pjmedia_snd_open_player( dev_id, clock_rate, nchannel, 106 133 nsamples, bits, &play_cb, NULL, 107 134 &strm); 135 } else { 136 status = pjmedia_snd_open( dev_id, dev_id, clock_rate, nchannel, 137 nsamples, bits, &rec_cb, &play_cb, NULL, 138 &strm); 108 139 } 109 140 110 141 if (status != PJ_SUCCESS) { 111 char errmsg[PJ_ERR_MSG_SIZE]; 112 113 pj_strerror(status, errmsg, sizeof(errmsg)); 114 printf( "Error: unable to open device %d for %s: %s (err=%d)\n", 115 dev_id, (capturing ? "capture" : "playback"), 116 errmsg, status); 117 return 1; 118 119 } else { 120 puts("Device opened successfully"); 121 } 142 app_perror("Unable to open device for capture", status); 143 return 1; 144 } 145 146 status = pjmedia_snd_stream_start(strm); 147 if (status != PJ_SUCCESS) { 148 app_perror("Unable to start capture stream", status); 149 return 1; 150 } 151 152 /* Let playback/capture runs for a while */ 153 pj_thread_sleep(1000); 122 154 123 155 pjmedia_snd_stream_close(strm); 156 157 if ((dir & PJMEDIA_DIR_CAPTURE) && rec_counter==0) { 158 printf("Error: capture stream was not running\n"); 159 return 1; 160 } 161 162 if ((dir & PJMEDIA_DIR_PLAYBACK) && play_counter==0) { 163 printf("Error: playback stream was not running\n"); 164 return 1; 165 } 166 167 puts("Success."); 124 168 return 0; 125 169 } … … 153 197 154 198 int dev_id; 155 int capturing;199 pjmedia_dir dir; 156 200 int clock_rate; 157 201 int nchannel; … … 159 203 160 204 dev_id = atoi(argv[1]); 161 capturing = (strcmp(argv[2], "r") == 0); 205 206 if (strcmp(argv[2], "rec")==0) 207 dir = PJMEDIA_DIR_CAPTURE; 208 else if (strcmp(argv[2], "play")==0) 209 dir = PJMEDIA_DIR_PLAYBACK; 210 else if (strcmp(argv[2], "both")==0) 211 dir = PJMEDIA_DIR_CAPTURE_PLAYBACK; 212 162 213 clock_rate = atoi(argv[3]); 163 214 nchannel = atoi(argv[4]); 164 215 bits = atoi(argv[5]); 165 216 166 return open_device(dev_id, capturing, clock_rate, nchannel, bits);217 return open_device(dev_id, dir, clock_rate, nchannel, bits); 167 218 168 219 } else {
Note: See TracChangeset
for help on using the changeset viewer.