[FIX] ZM 1.24.2: Opera, Safari and iPhone MJPEG capability

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

[FIX] ZM 1.24.2: Opera, Safari and iPhone MJPEG capability

Post by mastertheknife »

EDIT: I have now edited this thread and the fix to also include support for Safari users or people surfing with the iPhone's built in Safari browser.
Also, there is no need to do anything for Google chrome because its being detected as Mozilla\firefox.

If you are using the JPEG streaming mode (Motion JPEG) with the browser Opera or Safari, or even using your iPhone, there is no reason to use cambozola because all those browsers support MJPEG natively.
The problem: with ZM's CAN_STREAM setting set to "auto", ZM's auto detection believes those browsers don't support MJPEG, although they do.
This is because ZM's auto detection is slightly outdated and this fix will update it.
You can do the changes manually or use the patch below.

EDIT: If after this fix you experience flickering in Opera, here is how you fix it:
http://www.zoneminder.com/forums/viewto ... 1209#61209

In file include/functions.php, change the following which is at around line 823 (May vary from installation to installation):

Code: Select all

    elseif (ereg( 'Opera ([0-9].[0-9]{1,2})',$_SERVER['HTTP_USER_AGENT'],$logVersion))
To:

Code: Select all

    elseif (ereg( 'Opera/([0-9].[0-9]{1,2})',$_SERVER['HTTP_USER_AGENT'],$logVersion))

In around line 876 (May vary from installation to installation), change:

Code: Select all

function canStreamNative()
{
   return( ZM_CAN_STREAM == "yes" || ( ZM_CAN_STREAM == "auto" && (isNetscape() || isKonqueror()) ) );
}
To:

Code: Select all

function canStreamNative()
{
   return( ZM_CAN_STREAM == "yes" || ( ZM_CAN_STREAM == "auto" && (isNetscape() || isKonqueror() || isOpera() || isSafari()) ) );
}

In around line 840 (May vary from installation to installation), find this:

Code: Select all

function isNetscape()
{
    getBrowser( $browser, $version );

    return( $browser == "mozilla" );
}
Add this below it or above it:

Code: Select all

function isOpera() {
    getBrowser( $browser, $version );
    return( $browser == "opera" );
}
function isSafari() {
    getBrowser( $browser, $version );
    return( $browser == "safari" );
}


Or for those who prefer a patch (Generated on virgin ZM 1.24.2):

Code: Select all

--- original/web/includes/functions.php	2009-05-08 12:17:10.000000000 +0300
+++ patched/web/includes/functions.php	2010-04-13 22:44:27.000000000 +0300
@@ -820,7 +820,7 @@
                 $version = $logVersion[1];
                 $browser = 'konqueror';
         }
-    elseif (ereg( 'Opera ([0-9].[0-9]{1,2})',$_SERVER['HTTP_USER_AGENT'],$logVersion))
+    elseif (ereg( 'Opera/([0-9].[0-9]{1,2})',$_SERVER['HTTP_USER_AGENT'],$logVersion))
     {
         $version = $logVersion[1];
         $browser = 'opera';
@@ -844,6 +844,18 @@
     return( $browser == "mozilla" );
 }
 
+function isOpera()
+{
+    getBrowser( $browser, $version );
+    return( $browser == "opera" );
+}
+
+function isSafari()
+{
+    getBrowser( $browser, $version );
+    return( $browser == "safari" );
+}
+
 function isKonqueror()
 {
    getBrowser( $browser, $version );
@@ -875,7 +887,7 @@
 
 function canStreamNative()
 {
-   return( ZM_CAN_STREAM == "yes" || ( ZM_CAN_STREAM == "auto" && (isNetscape() || isKonqueror()) ) );
+   return( ZM_CAN_STREAM == "yes" || ( ZM_CAN_STREAM == "auto" && (isNetscape() || isKonqueror() || isOpera() || isSafari()) ) );
 }
 
 function canStreamApplet()

To apply, save the patch into a file, open a shell\bash, navigate to ZM's root folder (where index.php is) and execute:

Code: Select all

patch -p2 < /path/to/the/patch/file/you/just/stored

mastertheknife.
Last edited by mastertheknife on Tue Apr 13, 2010 10:08 pm, edited 4 times in total.
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Post by mastertheknife »

Bumped because of changes and additions.
MarcoP
Posts: 46
Joined: Wed Mar 24, 2010 1:46 pm

Post by MarcoP »

Before applying your patch I made Opera use Firefox user agent, Cambozola doesn't load anymore and I get the first and only image after 3-5 seconds wait.
I get the same results even after applying your patch (I let Opera identify it self as Opera).

Redraw instantly is set within the preferences.

I've tested whit two different 10.x versions but nothing.

What opera are you using? Any idea why it wont for me?
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Post by mastertheknife »

Thats strange. On my computer i use 64bit Opera 10.20 Alpha 1 on 64bit Gentoo Linux, but on my netbook i use Opera 9.64 for Windows.
Both work fine with motion jpeg and ZoneMinder.
Geo99M6Z
Posts: 10
Joined: Fri May 13, 2005 12:33 pm

Post by Geo99M6Z »

Works great !
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Post by mastertheknife »

Geo99M6Z wrote:Works great !
Glad to hear :D
hypercubedan
Posts: 3
Joined: Thu Sep 30, 2010 1:12 am
Location: CA

Post by hypercubedan »

worked for me!
DervMan
Posts: 23
Joined: Wed Feb 25, 2009 2:04 pm
Location: Bristol, UK

Post by DervMan »

All working now, re-typed everything manually and it worked :-/



-----------------------------------------------------------------------


Currently running 1.24.2 installed via apt-get on ubuntu.

I've manually modified the file as suggested but I get the following error

Code: Select all

==> /var/log/apache2/error.log <==
[Thu Jan 20 20:30:32 2011] [error] [client 172.16.0.1] PHP Deprecated:  Function ereg() is deprecated in /usr/share/zoneminder/includes/functions.php on line 808
[Thu Jan 20 20:30:32 2011] [error] [client 172.16.0.1] PHP Deprecated:  Function ereg() is deprecated in /usr/share/zoneminder/includes/functions.php on line 813
[Thu Jan 20 20:30:32 2011] [error] [client 172.16.0.1] PHP Deprecated:  Function ereg() is deprecated in /usr/share/zoneminder/includes/functions.php on line 808
[Thu Jan 20 20:30:32 2011] [error] [client 172.16.0.1] PHP Deprecated:  Function ereg() is deprecated in /usr/share/zoneminder/includes/functions.php on line 813
[Thu Jan 20 20:30:32 2011] [error] [client 172.16.0.1] PHP Fatal error:  Call to undefined function isOpera() in /usr/share/zoneminder/includes/functions.php on line 878
I checked and double checked the file and it looked good. I then tried using the patch file but got this.

Code: Select all

steve@NAS:/usr/share/zoneminder$ sudo patch -p2 < patch
patching file includes/functions.php
Hunk #1 FAILED at 820.
Hunk #2 FAILED at 844.
Hunk #3 FAILED at 875.
3 out of 3 hunks FAILED -- saving rejects to file includes/functions.php.rej
Any ideas?
floam
Posts: 5
Joined: Fri Dec 17, 2010 3:45 am

Re: [FIX] ZM 1.24.2: Opera, Safari and iPhone MJPEG capabili

Post by floam »

Please consider fixing this in SVN if you have not already!
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: [FIX] ZM 1.24.2: Opera, Safari and iPhone MJPEG capabili

Post by mastertheknife »

Hi floam,

Most of this is already in the SVN, except Opera support which is kind of non-functional ever since Opera 10 or so. I am not sure why its taking so long for Opera devs to fix MJPEG support.

mastertheknife
Kfir Itzhak.
Post Reply