Changeset 5982 for pjproject


Ignore:
Timestamp:
May 9, 2019 7:24:57 AM (5 years ago)
Author:
nanang
Message:

Re #1298: Updated PJMEDIA* to use PJ_ERROR consistently.

Location:
pjproject/trunk/pjmedia/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/ffmpeg_vid_codecs.c

    r5705 r5982  
    686686                status = PixelFormat_to_pjmedia_format_id(*p, &fmt_id); 
    687687                if (status != PJ_SUCCESS) { 
    688                     PJ_LOG(6, (THIS_FILE, "Unrecognized ffmpeg pixel " 
    689                                "format %d", *p)); 
     688                    PJ_PERROR(6, (THIS_FILE, status, 
     689                                  "Unrecognized ffmpeg pixel format %d", *p)); 
    690690                    continue; 
    691691                } 
  • pjproject/trunk/pjmedia/src/pjmedia-codec/h264_packetizer.c

    r5603 r5982  
    172172    { 
    173173        //pj_assert(!"MTU too small for H.264 single NAL packetization mode"); 
    174         PJ_LOG(2,("h264_packetizer.c", 
     174        PJ_LOG(2,(THIS_FILE, 
    175175                  "MTU too small for H.264 (required=%u, MTU=%u)", 
    176176                  nal_end - nal_start, pktz->cfg.mtu)); 
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/sdl_dev.c

    r5392 r5982  
    372372            case PJMEDIA_EVENT_WND_RESIZED: 
    373373                status = resize_disp(strm, &pevent.data.wnd_resized.new_size); 
    374                 if (status != PJ_SUCCESS) 
    375                     PJ_LOG(3, (THIS_FILE, "Failed resizing the display.")); 
     374                if (status != PJ_SUCCESS) { 
     375                    PJ_PERROR(3, (THIS_FILE, status, 
     376                                  "Failed resizing the display.")); 
     377                } 
    376378                break; 
    377379            case PJMEDIA_EVENT_WND_CLOSING: 
     
    11821184 
    11831185        status = sdl_create_window(strm, PJ_TRUE, sdl_info->sdl_format, hwnd); 
    1184         PJ_LOG(4, (THIS_FILE, "Re-initializing SDL with native window" 
    1185                               " %d: %s", hwnd->info.window, 
    1186                               (status == PJ_SUCCESS? "success": "failed"))); 
     1186        PJ_PERROR(4, (THIS_FILE, status, 
     1187                      "Re-initializing SDL with native window %d", 
     1188                      hwnd->info.window)); 
    11871189        return status;   
    11881190    } 
     
    13011303                                   &jq->sem); 
    13021304            if (status != PJ_SUCCESS) { 
    1303                 PJ_LOG(3, (THIS_FILE, "Failed growing SDL job queue size.")); 
     1305                PJ_PERROR(3, (THIS_FILE, status, 
     1306                              "Failed growing SDL job queue size.")); 
    13041307                return 0; 
    13051308            } 
     
    13121315                                       &jq->job_sem[i]); 
    13131316                if (status != PJ_SUCCESS) { 
    1314                     PJ_LOG(3, (THIS_FILE, "Failed growing SDL job " 
    1315                                           "queue size.")); 
     1317                    PJ_PERROR(3, (THIS_FILE, status, 
     1318                                  "Failed growing SDL job queue size.")); 
    13161319                    return 0; 
    13171320                } 
  • pjproject/trunk/pjmedia/src/pjmedia/delaybuf.c

    r3841 r5982  
    358358            /* Give all what delay buffer has, then pad with zeroes */ 
    359359            if (b->wsola) 
    360                 PJ_LOG(4,(b->obj_name,"Error generating frame, status=%d",  
    361                           status)); 
     360                PJ_PERROR(4,(b->obj_name, status, "Error generating frame")); 
    362361 
    363362            pjmedia_circ_buf_read(b->circ_buf, frame, buf_len); 
  • pjproject/trunk/pjmedia/src/pjmedia/echo_common.c

    r5186 r5982  
    402402    if (rc != PJ_SUCCESS) { 
    403403        /* Ooops.. no frame! */ 
    404         PJ_LOG(5,(echo->obj_name,  
    405                   "No frame from delay buffer. This will upset EC later")); 
     404        PJ_PERROR(5,(echo->obj_name, rc, 
     405                  "No frame from delay buffer (this will upset EC later)")); 
    406406        pjmedia_zero_samples(oldest_frm->buf, echo->samples_per_frame); 
    407407    } 
  • pjproject/trunk/pjmedia/src/pjmedia/sdp.c

    r5820 r5982  
    14341434    PJ_CATCH_ANY { 
    14351435         
    1436         char errmsg[PJ_ERR_MSG_SIZE]; 
    1437         pj_strerror(ctx.last_error, errmsg, sizeof(errmsg)); 
    1438  
    1439         PJ_LOG(4, (THIS_FILE, "Error parsing SDP in line %d col %d: %s", 
    1440                    scanner.line, pj_scan_get_col(&scanner), 
    1441                    errmsg)); 
     1436        PJ_PERROR(4, (THIS_FILE, ctx.last_error, 
     1437                      "Error parsing SDP in line %d col %d", 
     1438                      scanner.line, pj_scan_get_col(&scanner))); 
    14421439 
    14431440        session = NULL; 
  • pjproject/trunk/pjmedia/src/pjmedia/stream.c

    r5968 r5982  
    3939#define THIS_FILE                       "stream.c" 
    4040#define ERRLEVEL                        1 
    41 #define LOGERR_(expr)                   stream_perror expr 
     41#define LOGERR_(expr)                   PJ_PERROR(4,expr); 
    4242#define TRC_(expr)                      PJ_LOG(5,expr) 
    4343 
     
    269269static pj_int16_t zero_frame[2 * 30 * 16000 / 1000]; 
    270270 
    271 /* 
    272  * Print error. 
    273  */ 
    274 static void stream_perror(const char *sender, const char *title, 
    275                           pj_status_t status) 
    276 { 
    277     char errmsg[PJ_ERR_MSG_SIZE]; 
    278  
    279     pj_strerror(status, errmsg, sizeof(errmsg)); 
    280     PJ_LOG(4,(sender, "%s: %s [err:%d]", title, errmsg, status)); 
    281 } 
    282271 
    283272static void on_rx_rtcp( void *data, 
     
    749738                                           &frame_out); 
    750739            if (status != 0) { 
    751                 LOGERR_((port->info.name.ptr, "codec decode() error", 
    752                          status)); 
     740                LOGERR_((port->info.name.ptr, status, 
     741                         "codec decode() error")); 
    753742 
    754743                if (use_dec_buf) { 
     
    862851                                           0, frame); 
    863852            if (status != PJ_SUCCESS) { 
    864                 LOGERR_((port->info.name.ptr, "codec decode() error", 
    865                          status)); 
     853                LOGERR_((port->info.name.ptr, status, 
     854                         "codec decode() error")); 
    866855                pjmedia_frame_ext_append_subframe(f, NULL, 0, 
    867856                                            (pj_uint16_t)samples_per_frame); 
     
    13971386                                       &frame_out); 
    13981387        if (status != PJ_SUCCESS) { 
    1399             LOGERR_((stream->port.info.name.ptr, 
    1400                     "Codec encode() error", status)); 
     1388            LOGERR_((stream->port.info.name.ptr, status, 
     1389                    "Codec encode() error")); 
    14011390            return status; 
    14021391        } 
     
    14211410                                       &frame_out); 
    14221411        if (status != PJ_SUCCESS) { 
    1423             LOGERR_((stream->port.info.name.ptr, 
    1424                     "Codec encode() error", status)); 
     1412            LOGERR_((stream->port.info.name.ptr, status, 
     1413                    "Codec encode() error")); 
    14251414            return status; 
    14261415        } 
     
    14451434 
    14461435    if (status != PJ_SUCCESS) { 
    1447         LOGERR_((stream->port.info.name.ptr, 
    1448                 "RTP encode_rtp() error", status)); 
     1436        LOGERR_((stream->port.info.name.ptr, status, 
     1437                "RTP encode_rtp() error")); 
    14491438        return status; 
    14501439    } 
     
    17761765                                    &hdr, &payload, &payloadlen); 
    17771766    if (status != PJ_SUCCESS) { 
    1778         LOGERR_((stream->port.info.name.ptr, "RTP decode error", status)); 
     1767        LOGERR_((stream->port.info.name.ptr, status, "RTP decode error")); 
    17791768        stream->rtcp.stat.rx.discard++; 
    17801769        return; 
     
    19311920                                     payloadlen, &ts, &count, frames); 
    19321921        if (status != PJ_SUCCESS) { 
    1933             LOGERR_((stream->port.info.name.ptr, 
    1934                      "Codec parse() error", 
    1935                      status)); 
     1922            LOGERR_((stream->port.info.name.ptr, status, 
     1923                     "Codec parse() error")); 
    19361924            count = 0; 
    19371925        } else if (stream->detect_ptime_change && 
     
    20592047 
    20602048    if (status != 0) { 
    2061         LOGERR_((stream->port.info.name.ptr, "Jitter buffer put() error", 
    2062                 status)); 
     2049        LOGERR_((stream->port.info.name.ptr, status, 
     2050                 "Jitter buffer put() error")); 
    20632051        pkt_discarded = PJ_TRUE; 
    20642052        goto on_return; 
     
    21222110    if (bytes_read < 0) { 
    21232111        if (bytes_read != -PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK)) { 
    2124             LOGERR_((stream->port.info.name.ptr, "RTCP recv() error", 
    2125                     (pj_status_t)-bytes_read)); 
     2112            LOGERR_((stream->port.info.name.ptr, (pj_status_t)-bytes_read, 
     2113                     "RTCP recv() error")); 
    21262114        } 
    21272115        return; 
     
    27792767                         TRACE_JB_PATH_PREFIX "%s.csv", 
    27802768                         stream->port.info.name.ptr); 
    2781         status = pj_file_open(pool, trace_name, PJ_O_WRONLY, &stream->trace_jb_fd); 
     2769        status = pj_file_open(pool, trace_name, PJ_O_WRONLY, 
     2770                              &stream->trace_jb_fd); 
    27822771        if (status != PJ_SUCCESS) { 
    27832772            stream->trace_jb_fd = TRACE_JB_INVALID_FD; 
    2784             PJ_LOG(3,(THIS_FILE, "Failed creating RTP trace file '%s'", 
    2785                       trace_name)); 
     2773            PJ_PERROR(3,(THIS_FILE, status, 
     2774                         "Failed creating RTP trace file '%s'", trace_name)); 
    27862775        } else { 
    27872776            stream->trace_jb_buf = (char*)pj_pool_alloc(pool, PJ_LOG_MAX_SIZE); 
  • pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c

    r5853 r5982  
    395395{ 
    396396    if (err != PJ_SUCCESS) { 
    397         char errmsg[PJ_ERR_MSG_SIZE]; 
    398         pj_strerror(err, errmsg, sizeof(errmsg)); 
    399         PJ_LOG(4,(tp_ice->base.name,  
    400                   "Stopping ICE, reason=%s:%s", reason, errmsg)); 
     397        PJ_PERROR(4,(tp_ice->base.name, err, 
     398                     "Stopping ICE, reason=%s", reason)); 
    401399    } else { 
    402400        PJ_LOG(4,(tp_ice->base.name,  
     
    10611059                            &rem_m->attr[i]->value, &cand); 
    10621060        if (status != PJ_SUCCESS) { 
    1063             PJ_LOG(4,(tp_ice->base.name,  
    1064                       "Error in parsing SDP candidate attribute '%.*s', " 
    1065                       "candidate is ignored", 
    1066                       (int)rem_m->attr[i]->value.slen,  
    1067                       rem_m->attr[i]->value.ptr)); 
     1061            PJ_PERROR(4,(tp_ice->base.name, status, 
     1062                        "Error in parsing SDP candidate attribute '%.*s', " 
     1063                        "candidate is ignored", 
     1064                        (int)rem_m->attr[i]->value.slen,  
     1065                        rem_m->attr[i]->value.ptr)); 
    10681066            continue; 
    10691067        } 
     
    14911489                            &cand[cand_cnt]); 
    14921490        if (status != PJ_SUCCESS) { 
    1493             PJ_LOG(4,(tp_ice->base.name,  
    1494                       "Error in parsing SDP candidate attribute '%.*s', " 
    1495                       "candidate is ignored", 
    1496                       (int)attr->value.slen, attr->value.ptr)); 
     1491            PJ_PERROR(4,(tp_ice->base.name, status, 
     1492                        "Error in parsing SDP candidate attribute '%.*s', " 
     1493                        "candidate is ignored", 
     1494                        (int)attr->value.slen, attr->value.ptr)); 
    14971495            continue; 
    14981496        } 
     
    16711669                                            &pwd_attr->value); 
    16721670            if (status != PJ_SUCCESS) { 
    1673                 PJ_LOG(1,(tp_ice->base.name,  
    1674                           "ICE re-initialization failed (status=%d)!", 
    1675                           status)); 
     1671                PJ_PERROR(1,(tp_ice->base.name, status, 
     1672                             "ICE re-initialization failed!")); 
    16761673                return status; 
    16771674            } 
     
    17111708    status = start_ice(tp_ice, tmp_pool, rem_sdp, media_index); 
    17121709    if (status != PJ_SUCCESS) { 
    1713         PJ_LOG(1,(tp_ice->base.name,  
    1714                   "ICE restart failed (status=%d)!", 
    1715                   status)); 
     1710        PJ_PERROR(1,(tp_ice->base.name, status, "ICE restart failed!")); 
    17161711        return status; 
    17171712    } 
  • pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c

    r5860 r5982  
    515515#endif 
    516516 
    517     if (pjmedia_endpt_atexit(endpt, pjmedia_srtp_deinit_lib) != PJ_SUCCESS) 
    518     { 
     517    status = pjmedia_endpt_atexit(endpt, pjmedia_srtp_deinit_lib); 
     518    if (status != PJ_SUCCESS) { 
    519519        /* There will be memory leak when it fails to schedule libsrtp 
    520520         * deinitialization, however the memory leak could be harmless, 
     
    522522         * when the application terminates. 
    523523         */ 
    524         PJ_LOG(4, (THIS_FILE, "Failed to register libsrtp deinit.")); 
     524        PJ_PERROR(4, (THIS_FILE, status, 
     525                      "Failed to register libsrtp deinit.")); 
     526 
     527        /* Ignore this error */ 
     528        status = PJ_SUCCESS; 
    525529    } 
    526530 
     
    17581762    status = pjmedia_transport_media_stop(srtp->member_tp); 
    17591763    if (status != PJ_SUCCESS) 
    1760         PJ_LOG(4, (srtp->pool->obj_name, 
    1761                    "SRTP failed stop underlying media transport.")); 
     1764        PJ_PERROR(4, (srtp->pool->obj_name, status, 
     1765                      "SRTP failed stop underlying media transport.")); 
    17621766 
    17631767    /* Finally, stop SRTP */ 
  • pjproject/trunk/pjmedia/src/pjmedia/transport_srtp_sdes.c

    r5929 r5982  
    129129                                 crypto_suites[cs_idx].cipher_key_len); 
    130130            if (err != 1) { 
    131                 PJ_LOG(5,(THIS_FILE, "Failed generating random key")); 
     131                PJ_LOG(4,(THIS_FILE, "Failed generating random key " 
     132                          "(native err=%d)", err)); 
    132133                return PJMEDIA_ERRNO_FROM_LIBSRTP(1); 
    133134            } 
     
    160161 
    161162    /* Key transmitted via SDP should be base64 encoded. */ 
    162     status = pj_base64_encode((pj_uint8_t*)crypto->key.ptr, (int)crypto->key.slen, 
     163    status = pj_base64_encode((pj_uint8_t*)crypto->key.ptr, 
     164                              (int)crypto->key.slen, 
    163165                              b64_key, &b64_key_len); 
    164166    if (status != PJ_SUCCESS) { 
    165         PJ_LOG(5,(THIS_FILE, "Failed encoding plain key to base64")); 
     167        PJ_PERROR(4,(THIS_FILE, status, 
     168                     "Failed encoding plain key to base64")); 
    166169        return status; 
    167170    } 
     
    259262                              &itmp); 
    260263    if (status != PJ_SUCCESS) { 
    261         PJ_LOG(4,(THIS_FILE, "Failed decoding crypto key from base64")); 
     264        PJ_PERROR(4,(THIS_FILE, status, 
     265                     "Failed decoding crypto key from base64")); 
    262266        return status; 
    263267    } 
  • pjproject/trunk/pjmedia/src/pjmedia/vid_port.c

    r5948 r5982  
    10011001        { 
    10021002            status = pjmedia_vid_dev_stream_set_cap(vp->strm, 
    1003                                                     PJMEDIA_VID_DEV_CAP_FORMAT, 
    1004                                                     &vp->conv.conv_param.dst); 
     1003                                                PJMEDIA_VID_DEV_CAP_FORMAT, 
     1004                                                &vp->conv.conv_param.dst); 
    10051005            if (status != PJ_SUCCESS) { 
    1006                 PJ_LOG(3, (THIS_FILE, "failure in changing the format of the " 
    1007                                       "video device")); 
     1006                PJ_PERROR(3,(THIS_FILE, status, 
     1007                    "failure in changing the format of the video device")); 
    10081008                PJ_LOG(3, (THIS_FILE, "reverting to its original format: %s", 
    10091009                                      status != PJMEDIA_EVID_ERR ? "success" : 
  • pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c

    r5968 r5982  
    4141#define THIS_FILE                       "vid_stream.c" 
    4242#define ERRLEVEL                        1 
    43 #define LOGERR_(expr)                   stream_perror expr 
     43#define LOGERR_(expr)                   PJ_PERROR(4,expr) 
    4444#define TRC_(expr)                      PJ_LOG(5,expr) 
    4545#define SIGNATURE                       PJMEDIA_SIG_PORT_VID_STREAM 
     
    196196static pj_status_t decode_frame(pjmedia_vid_stream *stream, 
    197197                                pjmedia_frame *frame); 
    198  
    199 /* 
    200  * Print error. 
    201  */ 
    202 static void stream_perror(const char *sender, const char *title, 
    203                           pj_status_t status) 
    204 { 
    205     char errmsg[PJ_ERR_MSG_SIZE]; 
    206  
    207     pj_strerror(status, errmsg, sizeof(errmsg)); 
    208     PJ_LOG(4,(sender, "%s: %s [err:%d]", title, errmsg, status)); 
    209 } 
    210198 
    211199 
     
    645633                                    &hdr, &payload, &payloadlen); 
    646634    if (status != PJ_SUCCESS) { 
    647         LOGERR_((channel->port.info.name.ptr, "RTP decode error", status)); 
     635        LOGERR_((channel->port.info.name.ptr, status, "RTP decode error")); 
    648636        stream->rtcp.stat.rx.discard++; 
    649637        return; 
     
    826814 
    827815    if (status != 0) { 
    828         LOGERR_((channel->port.info.name.ptr, "Jitter buffer put() error",  
    829                 status)); 
     816        LOGERR_((channel->port.info.name.ptr, status, 
     817                 "Jitter buffer put() error")); 
    830818        pkt_discarded = PJ_TRUE; 
    831819        goto on_return; 
     
    867855    if (bytes_read < 0) { 
    868856        if (bytes_read != -PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK)) { 
    869             LOGERR_((stream->cname.ptr, "RTCP recv() error", 
    870                     (pj_status_t)-bytes_read)); 
     857            LOGERR_((stream->cname.ptr, (pj_status_t)-bytes_read, 
     858                     "RTCP recv() error")); 
    871859        } 
    872860        return; 
     
    968956                                            &has_more_data); 
    969957    if (status != PJ_SUCCESS) { 
    970         LOGERR_((channel->port.info.name.ptr, 
    971                 "Codec encode_begin() error", status)); 
     958        LOGERR_((channel->port.info.name.ptr, status, 
     959                "Codec encode_begin() error")); 
    972960 
    973961        /* Update RTP timestamp */ 
     
    997985                                        &rtphdrlen); 
    998986        if (status != PJ_SUCCESS) { 
    999             LOGERR_((channel->port.info.name.ptr, 
    1000                     "RTP encode_rtp() error", status)); 
     987            LOGERR_((channel->port.info.name.ptr, status, 
     988                    "RTP encode_rtp() error")); 
    1001989            return status; 
    1002990        } 
     
    10171005                enum { COUNT_TO_REPORT = 20 }; 
    10181006                if (stream->send_err_cnt++ == 0) { 
    1019                     LOGERR_((channel->port.info.name.ptr, 
    1020                              "Transport send_rtp() error", 
    1021                              status)); 
     1007                    LOGERR_((channel->port.info.name.ptr, status, 
     1008                             "Transport send_rtp() error")); 
    10221009                } 
    10231010                if (stream->send_err_cnt > COUNT_TO_REPORT) 
     
    10461033                                               &has_more_data); 
    10471034        if (status != PJ_SUCCESS) { 
    1048             LOGERR_((channel->port.info.name.ptr, 
    1049                      "Codec encode_more() error", status)); 
     1035            LOGERR_((channel->port.info.name.ptr, status, 
     1036                     "Codec encode_more() error")); 
    10501037            /* Ignore this error (?) */ 
    10511038            break; 
     
    12351222                                          (unsigned)frame->size, frame); 
    12361223        if (status != PJ_SUCCESS) { 
    1237             LOGERR_((channel->port.info.name.ptr, "codec decode() error", 
    1238                      status)); 
     1224            LOGERR_((channel->port.info.name.ptr, status, 
     1225                     "codec decode() error")); 
    12391226            frame->type = PJMEDIA_FRAME_TYPE_NONE; 
    12401227            frame->size = 0; 
     
    18441831        if (status != PJ_SUCCESS) { 
    18451832            stream->trace_jb_fd = TRACE_JB_INVALID_FD; 
    1846             PJ_LOG(3,(THIS_FILE, "Failed creating RTP trace file '%s'",  
    1847                       trace_name)); 
     1833            PJ_PERROR(3,(THIS_FILE, status, 
     1834                         "Failed creating RTP trace file '%s'",  
     1835                         trace_name)); 
    18481836        } else { 
    18491837            stream->trace_jb_buf = (char*)pj_pool_alloc(pool, PJ_LOG_MAX_SIZE); 
  • pjproject/trunk/pjmedia/src/pjmedia/vid_tee.c

    r3773 r5982  
    318318                                               frame, &frame_); 
    319319            if (status != PJ_SUCCESS) { 
    320                 PJ_LOG(3, (THIS_FILE, 
    321                                "Failed to convert frame for destination" 
    322                                " port %d (%.*s)", i, 
    323                                tee->dst_ports[i].dst->info.name.slen, 
    324                                tee->dst_ports[i].dst->info.name.ptr)); 
     320                PJ_PERROR(3, (THIS_FILE, status, 
     321                              "Failed to convert frame for destination" 
     322                              " port %d (%.*s)", i, 
     323                              tee->dst_ports[i].dst->info.name.slen, 
     324                              tee->dst_ports[i].dst->info.name.ptr)); 
    325325                continue; 
    326326            } 
  • pjproject/trunk/pjmedia/src/pjmedia/wsola.c

    r4537 r5982  
    528528    status = pjmedia_circ_buf_create(pool, wsola->buf_size, &wsola->buf); 
    529529    if (status != PJ_SUCCESS) { 
    530         PJ_LOG(3, (THIS_FILE, "Failed to create circular buf")); 
     530        PJ_PERROR(3, (THIS_FILE, status, "Failed to create circular buf")); 
    531531        return status; 
    532532    } 
Note: See TracChangeset for help on using the changeset viewer.