The past perfect continuous, had + been + present participle, describes an action which started in the past and continued up to another point in the past.
http://www.bbc.co.uk/learningenglish/english/course/intermediate/unit-14/session-2/activity-3