Ticket #5700: mythphone-uninit.patch

File mythphone-uninit.patch, 7.4 KB (added by Erik Hovland <erik@…>, 13 years ago)

initiliazes member variables in ctors

  • mythplugins/mythphone/mythphone/rtp.h

    Fix initialization in ctor defects in mythphone
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     mythplugins/mythphone/mythphone/rtp.h      |   61 ++++++++++++++++++++++------
     mythplugins/mythphone/mythphone/webcam.cpp |   48 ++++++++--------------
     mythplugins/mythphone/mythphone/webcam.h   |   16 +++++--
     3 files changed, 76 insertions(+), 49 deletions(-)
    
    diff --git a/mythplugins/mythphone/mythphone/rtp.h b/mythplugins/mythphone/mythphone/rtp.h
    index 5d13c23..2d42582 100644
    a b class rtp; 
    3939class RtpEvent : public QEvent
    4040{
    4141public:
    42     enum Type { RxVideoFrame = (QEvent::User + 300), RtpDebugEv, RtpStatisticsEv, RtpRtcpStatsEv };
    43 
    44     RtpEvent(Type t, QString s="") : QEvent((QEvent::Type)t) { text=s; }
    45     RtpEvent(Type t, rtp *r, QTime tm, int ms, int s1, int s2, int s3, int s4, int s5, int s6,
    46              int s7, int s8, int s9, int s10, int s11, int s12, int s13, int s14, int s15, int s16)
    47               : QEvent((QEvent::Type)t)
    48              { rtpThread=r; timestamp=tm; msPeriod = ms; pkIn=s1; pkOut=s2; pkMiss=s3; pkLate=s4;
    49                pkInDisc=s5; pkOutDrop=s6;
    50                byteIn=s7; byteOut=s8; bytePlayed=s9; framesIn=s10; framesOut=s11; framesInDisc=s12;
    51                framesOutDisc=s13; minPlayout=s14; avgPlayout=s15; maxPlayout=s16; }
    52     RtpEvent(Type t, rtp *r, QTime tm, int ms, int s1, int s2) : QEvent((QEvent::Type)t)
    53              { rtpThread=r; timestamp=tm; msPeriod = ms; rtcpFractionLoss=s1; rtcpTotalLoss=s2;}   
     42    enum Type {
     43        RxVideoFrame = (QEvent::User + 300), RtpDebugEv, RtpStatisticsEv,
     44        RtpRtcpStatsEv
     45    };
     46
     47    RtpEvent(Type t, QString s="")
     48        : QEvent((QEvent::Type)t),
     49          text(s),           rtpThread(NULL),
     50          timestamp(),       msPeriod(0),
     51          pkIn(0),           pkOut(0),
     52          pkOutDrop(0),      pkMiss(0),
     53          pkLate(0),         pkInDisc(0),
     54          framesIn(0),       framesOut(0),
     55          framesInDisc(0),   framesOutDisc(0),
     56          byteIn(0),         byteOut(0),
     57          bytePlayed(0),     rtcpFractionLoss(0),
     58          rtcpTotalLoss(0),  minPlayout(0),
     59          avgPlayout(0),     maxPlayout(0) { }
     60
     61    RtpEvent(Type t, rtp *r, QTime tm, int ms, int s1, int s2, int s3, int s4,
     62             int s5, int s6, int s7, int s8, int s9, int s10, int s11, int s12,
     63             int s13, int s14, int s15, int s16)
     64        : QEvent((QEvent::Type)t),
     65          text(""),          rtpThread(r),
     66          timestamp(tm),     msPeriod(ms),
     67          pkIn(s1),          pkOut(s2),
     68          pkOutDrop(s6),     pkMiss(s3),
     69          pkLate(s4),        pkInDisc(s5),
     70          framesIn(s10),     framesOut(s11),
     71          framesInDisc(s12), framesOutDisc(s13),
     72          byteIn(s7),        byteOut(s8),
     73          bytePlayed(s9),    rtcpFractionLoss(0),
     74          rtcpTotalLoss(0),  minPlayout(s14),
     75          avgPlayout(s15),   maxPlayout(s16) { }
     76
     77    RtpEvent(Type t, rtp *r, QTime tm, int ms, int s1, int s2)
     78        : QEvent((QEvent::Type)t),
     79          text(""),          rtpThread(r),
     80          timestamp(tm),     msPeriod(ms),
     81          pkIn(0),           pkOut(0),
     82          pkOutDrop(0),      pkMiss(0),
     83          pkLate(0),         pkInDisc(0),
     84          framesIn(0),       framesOut(0),
     85          framesInDisc(0),   framesOutDisc(0),
     86          byteIn(0),         byteOut(0),
     87          bytePlayed(0),     rtcpFractionLoss(s1),
     88          rtcpTotalLoss(s2), minPlayout(0),
     89          avgPlayout(0),     maxPlayout(0) { }
     90
    5491    ~RtpEvent()                 {  }
    5592    QString msg()               { return text;}
    5693    rtp *owner()                { return rtpThread; }
  • mythplugins/mythphone/mythphone/webcam.cpp

    diff --git a/mythplugins/mythphone/mythphone/webcam.cpp b/mythplugins/mythphone/mythphone/webcam.cpp
    index 9e345fb..3195f96 100644
    a b using namespace std; 
    3131#include "h263.h"
    3232#include "webcam.h"
    3333
    34 #ifdef WIN32
    3534QWidget *wcMainWidget;
     35#ifdef WIN32
    3636HWND wcMainHwnd;
    3737#endif
    3838
    3939Webcam::Webcam(QWidget *parent, QWidget *localVideoWidget)
     40    : hDev(0), DevName(""),
     41      picbuff1(NULL), imageLen(0),
     42      frameSize(0), fps(5),
     43      actualFps(fps), killWebcamThread(true), // Leave true whilst its not running
     44      wcFormat(0), wcFlip(false),
     45      cameraTime(), frameCount(0),
     46      totalCaptureMs(0)
    4047{
    41     hDev = 0;
    42     DevName = "";
    43     picbuff1 = 0;
    44     imageLen = 0;
    45     frameSize = 0;
    46     fps = 5;
    47     killWebcamThread = true; // Leave true whilst its not running
    48     wcFormat = 0;
    49     wcFlip = false;
    50 
    51 #ifndef WIN32
    52     (void)parent;
    53     (void)localVideoWidget;
    54     vCaps.name[0] = 0;
    55     vCaps.maxwidth = 0;
    56     vCaps.maxheight = 0;
    57     vCaps.minwidth = 0;
    58     vCaps.minheight = 0;
    59     memset(&vWin, 0, sizeof(struct video_window));
    60     vWin.width = 0;
    61     vWin.height = 0;
    62     vPic.brightness = 0;
    63     vPic.depth = 0;
    64     vPic.palette = 0;
    65     vPic.colour = 0;
    66     vPic.contrast = 0;
    67     vPic.hue = 0;
    68 
    69 #else
    7048    wcMainWidget = parent;
     49#ifdef WIN32
    7150    hwndWebcam = localVideoWidget->winId();
    7251    wcMainHwnd = hwndCap = capCreateCaptureWindow(NULL, WS_CHILD | WS_VISIBLE, 2, 2,
    7352                                     localVideoWidget->width()-4,
    7453                                     localVideoWidget->height()-4,
    7554                                     hwndWebcam, 1);
    76 
    7755    capSetCallbackOnVideoStream(hwndCap, frameReadyCallbackProc);
    7856    capSetCallbackOnError(hwndCap, ErrorCallbackProc) ;
    7957    capSetCallbackOnStatus(hwndCap, StatusCallbackProc) ;
    8058    capDriverConnect(hwndCap, 0);
    8159    capSetUserData(hwndCap, (long)this);
    8260#endif
     61
     62#ifdef __linux__
     63    (void)localVideoWidget;
     64    bzero(&vCaps, sizeof(vCaps));
     65    bzero(&vWin, sizeof(vWin));
     66    bzero(&vPic, sizeof(vPic));
     67    bzero(&vClips, sizeof(vClips));
     68#endif
    8369}
    8470
    8571
  • mythplugins/mythphone/mythphone/webcam.h

    diff --git a/mythplugins/mythphone/mythphone/webcam.h b/mythplugins/mythphone/mythphone/webcam.h
    index 0e66dae..eabc311 100644
    a b class WebcamEvent : public QEvent 
    8686public:
    8787    enum Type { FrameReady = (QEvent::User + 200), WebcamErrorEv, WebcamDebugEv  };
    8888
    89     WebcamEvent(Type t, wcClient *c) : QEvent((QEvent::Type)t) { client=c; }
    90     WebcamEvent(Type t, QString s) : QEvent((QEvent::Type)t) { text=s; }
     89    WebcamEvent(Type t, wcClient *c)
     90        : QEvent((QEvent::Type)t), client(c), text() { }
     91    WebcamEvent(Type t, QString s)
     92        : QEvent((QEvent::Type)t), client(NULL), text(s) { }
    9193    ~WebcamEvent() {}
    9294
    9395    wcClient *getClient() { return client; }
    class Webcam : public QThread 
    151153    void WebcamThreadWorker();
    152154
    153155#ifdef WIN32
    154     HWND hwndCap;
    155     HWND hwndWebcam;
    156156    static LRESULT CALLBACK frameReadyCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr);
    157157    static LRESULT CALLBACK ErrorCallbackProc(HWND hWnd, int nErrID, LPSTR lpErrorText);
    158158    static LRESULT CALLBACK StatusCallbackProc(HWND hWnd, int nID, LPSTR lpStatusText);
    class Webcam : public QThread 
    180180    int frameCount;
    181181    int totalCaptureMs;
    182182
    183     // OS specific data structures
     183    // OS specific members
    184184#ifdef WIN32
     185    HWND hwndCap;
     186    HWND hwndWebcam;
    185187    CAPTUREPARMS capParams;
    186188    BITMAPINFO bitmapInfo;
    187 #else
     189#endif
     190
     191#ifdef __linux__
    188192    struct video_capability vCaps;
    189193    struct video_window vWin;
    190194    struct video_picture vPic;