Copied code from ARBrowser-VideoStream. Minor updates.